SELECT column1 FROM table1 WHERE
EXISTS ( SELECT column1 FROM table2 WHERE table1.column1 = table2.column1 );
views:
88answers:
3
A:
Hi, try it like this
SELECT column1
FROM table1
INNER JOIN table2 ON table2.column1 = table1.column1
IordanTanev
2010-07-16 05:55:33
This makes no difference, except for probably now returning multiple rows if table2 is a child of table1. So then you'd need DISTINCT to fix it back to how EXISTS works...
gbn
2010-07-16 05:56:49
yes the query i wrote is the same as yours but more efficient. IF your query doesn't work please tell what is the problem. Some table schemes will help too
IordanTanev
2010-07-16 06:03:44
@IordanTanev: can you show me where it say JOIN is more efficient then EXISTS please? For my side, see these http://stackoverflow.com/questions/2019958 or this http://stackoverflow.com/questions/2177346/
gbn
2010-07-16 06:08:19
Mr Tanev, it may be more efficient but it doesn't do the same thing, as gbn pointed out. Doing the wrong thing quickly is not an improvement on doing the right thing slowly, although many managers seem to think it is.
Brian Hooper
2010-07-16 08:10:18
A:
Unless I miss something, isnt this just a normal join?
select table1.column1 from table1, table2 where table1.column1 = table2.column1;
Fadrian Sudaman
2010-07-16 05:56:14
No, not really. See my comment to lordanTanev's answer. You haven't posted a JOIN anyway.
gbn
2010-07-16 05:57:35
JOIN keyword is introduced in ANSI92, but prior to that JOIN is done through where clause. Internally it may be interpreted differently from INNER JOIN (i dont know), but to my knowledge this is still well supported and recognize as JOIN using the traditional syntax?
Fadrian Sudaman
2010-07-16 06:51:04
Found this post here that discuss about what I said abovehttp://stackoverflow.com/questions/334201/why-isnt-sql-ansi-92-standard-better-adopted-over-ansi-89
Fadrian Sudaman
2010-07-16 07:00:33
A:
answer:
SELECT column2 FROM table1 WHERE
EXISTS ( SELECT column2 FROM table2 WHERE table1.column2 = table2.column2 );
cache
2010-07-16 06:05:40
out of minddddddddddd..........atleast you get one vote in this question
Pranay Rana
2010-07-16 06:09:53