国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > MySQL > 正文

MySQL多表之間字段的匹配實現(xiàn)代碼

2024-07-24 13:01:11
字體:
來源:轉載
供稿:網友

復制代碼 代碼如下:


$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, '%')

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 二连浩特市| 赣榆县| 横山县| 阳原县| 富川| 淅川县| 双流县| 天镇县| 霍山县| 高唐县| 海伦市| 明水县| 泰州市| 余姚市| 本溪市| 明星| 贵德县| 筠连县| 桐梓县| 雷州市| 万全县| 新野县| 申扎县| 林西县| 井研县| 治多县| 区。| 苏尼特左旗| 离岛区| 蒙城县| 新干县| 崇义县| 卢氏县| 佛冈县| 邢台县| 宁阳县| 西丰县| 禄劝| 朔州市| 新蔡县| 富宁县|