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

时间:2022-07-21 19:39:50

i have a variable with value as the result of following query

我有一个带有值的变量作为以下查询的结果

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

its result stored in varible $result,in another page i want use this $result on a new query in where condition as the following

它的结果存储在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

how can i use this condition in query?

我怎样才能在查询中使用这个条件?

1 个解决方案

#1


0  

I'm not sure to understand why you can't use somthing simple like this :

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

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

#1


0  

I'm not sure to understand why you can't use somthing simple like this :

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

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