Re: What replaces IN?

2004-02-06 Thread Brent Baisley
IN is supported in 4.1, I'm not sure about 4.0. But any, you can do you query like this: select table1.* from table1 left join table2 on table1.item_id=table2.item_id where table2.item_id is not null I think that's right. It may actually be quicker than using IN. On Feb 6, 2004, at 2:20 PM,

Re: What replaces IN?

2004-02-06 Thread Michael Stassen
IN is supported in mysql, but subqueries do not work before 4.1.x. You could rewrite your query with a join, though. Something like: SELECT table1.* FROM table1, table2 WHERE table1.item_id = table2.item_id See http://www.mysql.com/doc/en/Rewriting_subqueries.html for more. Michael Scott

RE: What replaces IN?

2004-02-06 Thread Mike Johnson
From: Scott Purcell [mailto:[EMAIL PROTECTED] I am trying to run the below query, and believe that the 'IN' is not supported in mysql. What is the 'IN' replacement? I tried exists and that doesn't work. select * from table1 where item_id IN (select item_id from table2) IN has been

Re: What replaces IN?

2004-02-06 Thread Michael Stassen
This will work, but there's no reason to use a LEFT JOIN here. With a LEFT JOIN, you get a row for each item_id in table1 that does not have a corresponding item_id in table2, with the table2 fields set to NULL. You then have to filter these out with your WHERE clause. Just use a simple

Re: What replaces IN?

2004-02-06 Thread Brent Baisley
My thinking on using a left join was that there was not a one to one relationship between the tables, otherwise the data would be in one table. So a regular join would produce duplicate records if there was a one to many relationship between table1 and table2. A left join would assure a

Re: What replaces IN?

2004-02-06 Thread Michael Stassen
Brent Baisley wrote: My thinking on using a left join was that there was not a one to one relationship between the tables, otherwise the data would be in one table. So a regular join would produce duplicate records if there was a one to many relationship between table1 and table2. A left join