SQL is used to access to database in MySQL. It's very common and easy to learn.
In this section, I will introduce some useful sql statement.
It's used to check how MySQL process your queries.
You can check how many record that your queries will process, which index used, ..... And it's useful to optimize your query to create better query.
Syntax : EXPLAIN SELECT/UPDATE.............
It's used to get definition of table or database.
In case you need to check the encoding that table/database are using or current storage engine, it's very useful.
Know about definition of table or database is very useful when you get problem with your system about charset, transaction, or performance.
Syntax :
This statement is used to limit the number of record that query processes.
It's almost used in pagination data but there is very important usage of limit statement is : limit the number of record process while update, delete. It makes sense in case process data in production environment, it can make sure your query does not process the number of records more than you expected, so it avoid the mistake when update or delete data in production environment.
Syntax :
SELECT [.....fields...] FROM 'table' WHERE [....conditions....] LIMIT [number of row]
UPDATE 'table' SET [...expression...] WHERE [...conditions..] LIMIT [number of row]
In case you don't want to use join or can not use join , 'where in' is help to collect multiple record without execute multiple query when execute array in server (PHP, Java,...).
The conditions use with 'where in' statement can use index.
Syntax :