[prog] MySQL & 'IN'
Dominik Schramm
dominik.schramm at gmxpro.net
Sat Jul 17 17:36:44 EST 2004
Hi Karine,
Karine Proot <kproot at nerim.net> writes:
> SQL-query :
>
> SELECT sbt_id
> FROM subtypes
> WHERE sbt_id
> IN (
> SELECT tst_id_sbt AS sbt_id
Don't know if that affects the result, but why "AS sbt_id"?
I would try without that; it's not needed since you don't
refer to sbt_id in the subquery.
Are the column types of sbt_id and tst_id_sbt compatible?
Maybe this is some kind of name conflict;
does it work if you rewrite "AS sbt_id" as
"AS my_sbt_id" or something else that is not identical to
the column name of the main query.
> FROM types_subtypes
> )
> LIMIT 0 , 30
>
> MySQL said:
>
> #1064 - You have an error in your SQL syntax. [...]
> [...]
>
> [...] a nice example:
>
> SELECT s1 FROM t1 WHERE s1 IN (SELECT s1 FROM t2);
>
> Where is the difference ?
The "AS ..." in the query part is the only difference I can see.
However, this is allowed, as these examples here show:
http://dev.mysql.com/doc/mysql/en/Correlated_subqueries.html
hope this helps.
regards,
dominik
More information about the Programming
mailing list