MySQL查询之间有什么区别

When I manually update a database in phpMyAdmin this is the code it uses:

UPDATE  `test`.`users` SET  `number` =  '12' WHERE  `users`.`id` =1;

This is the code I normally use in php when I write queries manually:

UPDATE `users` SET  `number` =  '12' WHERE `id` =1;

What is the difference? More importantly, which is better to use and why? Please answer the why, Thank You.

The one phpMyAdmin just includes the database name as well as the table name.

In PHP, this is generally not needed, because you specify the database using mysqli_select_db or mysqli_connect.

Both are equivalent; the only difference is the way the database is selected. In the first one, the database is specified explicitly in the query, in the second one, the database name is implied, since you specify it with mysqli_select_db or mysqli_connect.

The one used by phpMyAdmin is it adds name of database which is normally not used in our regular practice but this is very good idea to use in cases when we have multiple database to connect and have same table names in those databases

For easy explanation,

on your first statement you just include an alias on part of table and fields to be display

and for the second was the vice versa of your first statement

but I refer to use the first statement, because when you had multiple join comes-up to your query it will be difficult to read so we need to use alias and it is a best practice for this

but when your just querying a single table its nice the second query statement

I hope it helps you,

Joven