September 4th, 2000, 05:34 PM
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', ...)
September 5th, 2000, 12:40 AM
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';
September 5th, 2000, 01:08 PM
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 ?
September 5th, 2000, 05:06 PM
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.
September 5th, 2000, 05:25 PM
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
Left Join (SELECT fields
FROM junk) as Table2
on Table1.key = Table2.FKey
Thanks for the help.
September 5th, 2000, 08:38 PM
September 6th, 2000, 10:06 AM
That is a serious limitation... Hope they fix it soon.