Browsed by
Category: Blog

How to search second maximum(second highest) salary value(integer)from table employee (field salary)in the manner so that mysql gets less load?

How to search second maximum(second highest) salary value(integer)from table employee (field salary)in the manner so that mysql gets less load?

By below query we will get second maximum(second highest) salary value(integer)from table employee (field salary)in the manner so that mysql gets less load? SELECT DISTINCT(salary) FROM employee order by salary desc limit 1 , 1 ; (This way we will able to find out 3rd highest , 4th highest salary so on just need to change limit condtion like LIMIT 2,1 for 3rd highest and LIMIT 3,1 for 4th some one may finding this way useing below query that taken…

Read More Read More

What is MySQL?

What is MySQL?

MySQL is a multithreaded, multi-user SQL database management system which has more than 11 million installations. It is the world’s second most popular and widely-used open source database. It is interesting how MySQL name was given to this query language. The term My is coined by the name of the daughter of co-founder Michael Widenius’s daughter, and SQL is the short form of Structured Query Language. Using MySQL is free of cost for the developer, but enterprises have to pay…

Read More Read More

How to insert data in MySQL?

How to insert data in MySQL?

We can insert data in a MySQL table using the INSERT STATEMENT. This statement allows us to insert single or multiple rows into a table. The following is the basic syntax to insert a record into a table: INSERT INTO table_name ( field1, field2,…fieldN ) VALUES ( value1, value2,…valueN ); If we want to insert more than one rows into a table, use the below syntax: INSERT INTO table(field1, field2,…fieldN) VALUES (value1, value 2, …), (value1, value2, …), … (value1,…

Read More Read More

How does indexing works in MySQL?

How does indexing works in MySQL?

Indexing is a process to find an unordered list into an ordered list. It helps in maximizing the query’s efficiency while searching on tables in MySQL. The working of MySQL indexing is similar to the book index. Suppose we have a book and want to get information about, say, searching. Without indexing, it is required to go through all pages one by one, until the specific topic was not found. On the other hand, an index contains a list of…

Read More Read More

What does “i_am_a_dummy flag” do in MySQL?

What does “i_am_a_dummy flag” do in MySQL?

The “i_am_a_dummy flag” enables the MySQL engine to refuse any UPDATE or DELETE statement to execute if the WHERE clause is not present. Hence it can save the programmer from deleting the entire table my mistake if he does not use WHERE clause. The “i_am_a_dummy” flag in MySQL is a compilation flag used during MySQL source code compilation. When enabled, it allows certain sections of code to be compiled with less optimization. This flag is primarily used for debugging purposes…

Read More Read More

Write a query to count the number of rows of a table in MySQL

Write a query to count the number of rows of a table in MySQL

SELECT COUNT user_id FROM users; To count the number of rows in a table in MySQL, you can use the COUNT() function along with the SELECT statement. Here’s the query: SELECT COUNT(*) AS row_count FROM your_table_name; Replace your_table_name with the name of the table you want to count the rows for. This query will return the number of rows in the specified table.

How can we run batch mode in MySQL?

How can we run batch mode in MySQL?

To perform batch mode in MySQL, we use the following command: mysql; mysql mysql.out; To run MySQL in batch mode, you can use the command-line tool and pass SQL statements from a file rather than typing them interactively. This is particularly useful for executing a series of SQL commands or scripts. You can run MySQL in batch mode using the following command: mysql -u username -p password database_name < batch_file.sql Replace “username” with your MySQL username, “password” with your password,…

Read More Read More

MySQL Interview Questions – Set 06

MySQL Interview Questions – Set 06

What is REGEXP? REGEXP is a pattern match using a regular expression. The regular expression is a powerful way of specifying a pattern for a sophisticated search. Basically, it is a special text string for describing a search pattern. To understand it better, you can think of a situation of daily life when you search for .txt files to list all text files in the file manager. The regex equivalent for .txt will be .*.txt. What are the drivers in…

Read More Read More

How to delete a row in MySQL?

How to delete a row in MySQL?

We can delete a row from the MySQL table using the DELETE STATEMENT within the database. The following is the generic syntax of DELETE statement in MySQL to remove one or more rows from a table: DELETE FROM table_name WHERE Condition_specified; It is noted that if we have not specified the WHERE clause with the syntax, this statement will remove all the records from the given table.