我是靠谱客的博主 跳跃天空,这篇文章主要介绍MySQL多表之间字段的匹配实现代码,现在分享给大家,希望可以做个参考。

复制代码 代码如下:

$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]."");
while($r=$empire->fetch($sql))
{
$title=$r['title'];
$lianxi=$r['lianxi'];
$dizhi=$r['dizhi'];
}

如下:两个表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多表之间字段内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(159)

评论列表共有 0 条评论

立即
投稿
返回
顶部