如何在另一个查询的条件中使用子查询?

时间:2013-09-24 06:13:01

标签: php mysql sql

我有一个带有值的变量作为后续查询的结果

select concat_ws(',',name,age) from table1 
inner join table2 on table1.id=table2.id 
where table1.height=150

其结果存储在varible $ result 中,在另一个页面中,我希望在新查询中使用此$ result,其中condition的条件如下

select address, state form table1 
where (**select concat_ws(',',name,age) from table1 inner join table2 
on table1.id=table2.id**)as val=$result

我如何在查询中使用此条件?

1 个答案:

答案 0 :(得分:0)

我不确定为什么你不能使用像这样简单的东西:

SELECT address, state FROM table1 
INNER JOIN table2 ON table1.id=table2.id 
WHERE concat_ws(',',name,age) = '$result'
相关问题