Home > Database > Mysql Tutorial > MySQLJOINUSING()用法_MySQL

MySQLJOINUSING()用法_MySQL

PHP中文网
Release: 2016-05-27 14:12:40
Original
1111 people have browsed it

MySQLJOINUSING()用法_MySQL

1 using()用于两张表的join查询,要求using()指定的列在两个表中均存在,并使用之用于join的条件。  示例:

 select a.*, b.* from a left join b using(colA);
Copy after login

等同于:

select a.*, b.* from a left join b on a.colA = b.colA;
Copy after login

2 多表查询就使用多个这样的join。 示例:

select a.*, b.* from a left join b using(colA) left join c using(colB);
Copy after login

要求colA在a, b中均存在,colB在a, c表中均存在。


总之,using() 只是join中指定连接条件的简写,在简单的连接中常用。在列名称不同时或连接条件复杂时就无法用了,使用 a left join b on ... 是更常见的做法。

以上就是MySQLJOINUSING()用法_MySQL的内容,更多相关内容请关注PHP中文网(www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template