Query of MYSQL connected tables and usage of aliases
MYSQL connected table query is a query between two tables or more tables, which queries all data by means of foreign keys, resulting in field duplication in the query process. In order to distinguish this situation, database design aliases, some tables are very long, can also use aliases.
1. Join tables to query INNER JOIN, LEFT JOIN,RIGHT JOIN
INNER JOIN (inner join, or equivalent join): gets the record of the matching relationship between the fields in two tables.
LEFT JOIN (left join): gets all the records in the left table, even if there are no matching records in the right table.
RIGHT JOIN (right join): contrary to LEFT JOIN, it is used to get all the records in the right table, even if there is no corresponding matching record in the left table.
2, example
Inner chain reads intersecting data
Mysql > SELECT a.huthon_id, a.huthon_author, b.huthon_count FROM huthon_tbl a, tcount_tbl b WHERE a.runoob_author = b.runoob_author
The left side reads the data on the left.
Mysql > SELECT a.huthon_id, a.huthon_author, b.huthon_count FROM runoob_tbl a LEFT JOIN tcount_tbl b ON a.runoob_author = b.runoob_author
The right chain reads the data on the right.
Mysql > SELECT a.huthon_id, a.huthon_author, b.huthon_count FROM runoob_tbl a RIGHT JOIN tcount_tbl b ON a.runoob_author = b.runoob_author
3, the use of aliases
Field huthon_id as A1
Table gdhuthon as huthon
The article is from http://www.huthon.com.