[prog] MySQL & 'IN'

Karine Proot kproot at nerim.net
Sat Jul 17 20:05:23 EST 2004


Thanks Dominik and Terri for replying.

On Sat, 2004-07-17 at 17:36, "Dominik Schramm" wrote: 
> 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.
Ah, sorry for the confusion, I added it to see if it would work better. It didn't work without it either.

> Are the column types of sbt_id and tst_id_sbt compatible?
Yup.

> 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.
No luck.

> 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
Indeed, I learned something at least :)


On Sat, 2004-07-17 at 18:50, Terri Oda wrote:
> Which version of MySQL are you using?  Sub-select statements haven't 
> been available in mysql for very long, I don't think, so make extra 
> sure that the version you're using is one that supports them.  (I tend 
> to look at the docs online because I like the user comments, which 
> leads me to occasionally choose the wrong syntax.  If you're looking at 
> the docs locally, this probably isn't your problem.)
This may be the root of the problem. I know which version I'm using
(4.0.15a), but can't find out when sub-select statements were added to
MySQL.
I do look at the docs online, so I guess this is the first thing to look
for. Do you have any clue about how to find out which MySQL accepts what
?

> Have you tried this query as two queries to see if that works?  (eg: 
> query #1 to make a temporary table with the data from types_subtypes, 
> query #2 from that table.)
Yup, did that to debug the query.
In fact, I even created tables t1 and t2 with field s1 to see wether
exactly copy/pasting the doc example would work or not.
It didn't, so now I'm about sure it's a version problem.

Karine



More information about the Programming mailing list