Home > Database > Mysql Tutorial > body text

PHP MySQL多表联查SQL语句笔记

WBOY
Release: 2016-06-07 17:52:27
Original
1342 people have browsed it

联系查询在mysql中是常用的,用来把多个用按一个指定的参数来查找我们想要的内容,下面只讲到了两个表,如果多表我们直接加多表即可。

简单方法

 代码如下 复制代码

SELECT * FROM table1 n, table2 i WHERE n.itemid = i.itemid

左连接

 代码如下 复制代码

select * from tab a left join tab1 b on a.id=b.id

右连接

 代码如下 复制代码


select * from tab a right join tab1 b on a.id=b.id

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template