所以我有一个声明:
$r = mysql_query("Select type from boats where type like '%speed%'");
然后我可以将构造的资源应用于另一个查询吗?
$r2 = mysql_query("select * from assets where type in ".$r);
我正在尝试做类似
的事情 select * from assets where type in (select type from boats where type like '%speed%')
答案 0 :(得分:2)
不,你不能这样做。
但你可以结合使用sql。
$sql = "Select type from boats where type like '%speed%'";
$r = mysql_query($sql);
$r2 = mysql_query("select * from assets where type in ($sql)");
或者代替子查询,您可以使用连接。
$r2 = mysql_query("select a.* from assets a
join boats b on a.type = b.type and b.type like '%speed%'");