发布于 2016-03-06 21:58:06 | 102 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的Mysql教程,程序狗速度看过来!

Mysql关系型数据库管理系统

MySQL是一个开放源码的小型关联式数据库管理系统,开发者为瑞典MySQL AB公司。MySQL被广泛地应用在Internet上的中小型网站中。由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,许多中小型网站为了降低网站总体拥有成本而选择了MySQL作为网站数据库。


本文主要介绍下MySQL多表之间字段的匹配;如tag表中name匹配info中的name,接下来详细介绍下,感兴趣的你可以参考下哈
 
$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, '%') 


最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务