『MySQL』多表之间字段的匹配
2013-05-03 20:30
190 查看
1 $sql=$empire->query("select table.title,lianxi,table.dizhi,table.id from table,table1 where table1.sid like concat( '%|',table.id,'|%') and table1.id=".$navinfor[id].""); 2 while($r=$empire->fetch($sql)) 3 { 4 $title=$r['title']; 5 $lianxi=$r['lianxi']; 6 $dizhi=$r['dizhi']; 7 }如下:两个表info,tag
info 表
id name
1 aa和bb
2 bb和cc
3 ee和dd
tag表
1 aa
2 bb
tag表中 name 匹配 info 中的name
这样写就有问题: select info.id, info.name from tag,info where info.name like ‘%'+tag.name+'%'
正确:
select info.id, info.name from tag,info where info.name like concat( '%',tag.name, '%')
相关文章推荐
- 『MySQL』多表之间字段的匹配
- 『MySQL』多表之间字段的匹配
- MySQL多表之间字段的匹配实现代码
- MySQL LIKE 用法:搜索匹配字段中的指定内容
- mysql concat_ws 与 concat 多字段模糊匹配应用
- mysql 中执行的 sql 注意字段之间的反向引号和单引号
- 两个表之间多字段的匹配!
- MySQL的统计总数count(*)与count(id)或count(字段)的之间的各自效率性能对比
- hibernate与mysql之间的字段映射关系
- 多表联查,两表之间相互关联,不一定需要有主外键关系,字段匹配就行
- mysql利用CONCAT进行关键字查询,多字段匹配
- MySQL LIKE 用法:搜索匹配字段中的指定内容
- mysql正则匹配解决查询一个字段是否在另一个字段中
- MYSQL不同字段之间四则运算
- 查询sql中常用到 like 进行字段和字符之间的匹配
- mysql查询逗号分隔字段匹配的值,可且可或
- 64位操作系统,mysql ODBC 驱动程序和应用程序之间的体系结构不匹配
- mysql多个数据表进行字段匹配
- MySQL的统计总数count(*)与count(id)或count(字段)的之间的各自效率性能对比