|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi there.
I'd like to know why SELECT ... FROM ... WHERE variable IN (SELECT ... FROM ... WHERE ...) doesn't work, although it works if I write the result of the second query as IN arguments, like SELECT ... FROM ... WHERE variable IN ('variable1', variable2', 'variable3', ...) Thanks - J0f |
|
#2
|
|||
|
|||
|
That's known as a sub-select. MySQL does not currently support sub-selects.
If your queries are sufficiently simple, you can work around it: select t.* from table1 t, table2 t2 where t.variable=t2.somefield and t2.someotherfield='foo'; |
|
#3
|
|||
|
|||
|
with php/mysql, do I have to :
- do my subquery first - output the result as a text variable - do the initial query with subselection of the previous results ? Thanx - J0f |
|
#4
|
|||
|
|||
|
You can either do a select to build the IN clause or join the tables. If you want a detailed example, post your non-working query in it's entirety.
|
|
#5
|
|||
|
|||
|
I think that this question falls in the same line as this thread so I am going to ask it.
Is this considered the same as a sub-query that is not supported? SELECT Table1.fields, Table2.fields FROM Table1 Left Join (SELECT fields FROM junk) as Table2 on Table1.key = Table2.FKey Thanks for the help. |
|
#6
|
|||
|
|||
|
Yes.
|
|
#7
|
|||
|
|||
|
That is a serious limitation... Hope they fix it soon.
|
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > 'in' statement in queries |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|