php mysql 查询只取第一条!

[复制链接]
查看11 | 回复4 | 2013-3-28 20:57:48 | 显示全部楼层 |阅读模式
这样不行,你要先遍历table2,取出id到数组,然后循环这个数组,对每个id值再从table1中查找...
回复

使用道具 举报

千问 | 2013-3-28 20:57:48 | 显示全部楼层
$query = mysql_query("select * from table1 where id in (select id from table2) limit 0,7 "); while($rs = mysql_fetch_array($query)){print:("$rs[id]");} 或者这么写 $query = $mysql_qu...
回复

使用道具 举报

千问 | 2013-3-28 20:57:48 | 显示全部楼层
$query = $mysql_query("select * from table1 where id in (select id from table2) limit 0,7 ");//mysql_query是一个php函数,函数怎么能加$了 while($rs = $mysql_fetch_array($query)){ print:("$rs[i...
回复

使用道具 举报

千问 | 2013-3-28 20:57:48 | 显示全部楼层
看着很别扭啊试试这个$query = mysql_query("select * from table1 where id in(select id from table2) limit 0,7");while($rs = mysql_fetch_array($query)){echo $rs["id"];}...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行