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 … Read more

Use a regular expression to find records. Use “REGEXP BINARY” to force case-sensitivity. This finds any record beginning with r

mysql> SELECT * FROM tablename WHERE rec RLIKE “^r”; To find records beginning with “r” in MySQL with case sensitivity enforced, you would use the following query: sql SELECT * FROM your_table WHERE your_column REGEXP BINARY ‘^r’; This query uses the REGEXP BINARY operator to enforce case sensitivity, and ^r as the regular expression pattern … Read more

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 … Read more

How to Create Table show Example

mysql> CREATE TABLE [table name] (firstname VARCHAR(20), middleinitial VARCHAR(3), lastname VARCHAR(35),suffix VARCHAR(3),officeid VARCHAR(10),userid VARCHAR(15),username VARCHAR(8),email VARCHAR(35),phone VARCHAR(25), groups VARCHAR(15),datestamp DATE,timestamp time,pgpemail VARCHAR(255)); To create a table in MySQL, you can use the CREATE TABLE statement followed by the table name and the list of columns with their data types and any constraints. Here’s an example: … Read more

Restore database (or database table) from backup

# [mysql dir]/bin/mysql -u username -ppassword databasename < /tmp/databasename.sql To restore a database or a specific table from a backup in MySQL, you typically use the mysql command-line client or a similar tool. Here’s a general approach: Ensure you have a backup: First, make sure you have a recent backup of the database or table … Read more