Home >Database >Mysql Tutorial >mysql 多表连接查询实例

mysql 多表连接查询实例

WBOY
WBOYOriginal
2016-06-01 09:57:101197browse

如下:两个表info,tag 

info 表 
id name 
1 aa和bb 
2 bb和cc 
3 ee和dd 

tag表 
1 aa 
2 bb 
tag表中 name 匹配 info 中的name 

这样写就有问题: 

<code class="language-sql">select info.id, info.name from tag,info where info.name like ‘%'+tag.name+'%' </code>

 

正确: 

<code class="language-sql">select info.id, info.name from tag,info where info.name like concat( '%',tag.name, '%') </code>

Statement:
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