Connecting Tech Pros Worldwide Help | Site Map

Alternate for INTERSECT in mysql 4.1.15

bzb bzb is offline
Newbie
 
Join Date: May 2007
Posts: 3
#1: May 31 '07
hi ALL,
I have a situation to use INTERSECT in my query, but INTERSECT is not supported in "mysql 4.1.15".
Can anyone explain me how to tackle this problem..... !
Also, is there any version of mysql which allows the usage of INTERSECT ?


Thank you !

bzb...
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#2: May 31 '07

re: Alternate for INTERSECT in mysql 4.1.15


Heya, bzb. Welcome to TSDN!

Quote:

Originally Posted by bzb

I have a situation to use INTERSECT in my query, but INTERSECT is not supported in "mysql 4.1.15".
Can anyone explain me how to tackle this problem..... !

The closest thing I could suggest would be to use a JOIN combined with SELECT DISTINCT.

Using the example on this page, I would probably do something along the lines of:

Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT `Store_Information`.`date` FROM `Store_Information`, `Internet_Sales` WHERE `Store_Information`.`date` = `Internet_Sales`.`date`;
  2.  
Or you could probably just do this:

Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT `date` FROM (`Store_Information` LEFT JOIN `Internet_Sales` USING(`date`));
  2.  
bzb bzb is offline
Newbie
 
Join Date: May 2007
Posts: 3
#3: May 31 '07

re: Alternate for INTERSECT in mysql 4.1.15


Quote:

Originally Posted by pbmods

Heya, bzb. Welcome to TSDN!



The closest thing I could suggest would be to use a JOIN combined with SELECT DISTINCT.

Using the example on this page, I would probably do something along the lines of:

Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT `Store_Information`.`date` FROM `Store_Information`, `Internet_Sales` WHERE `Store_Information`.`date` = `Internet_Sales`.`date`;
  2.  
Or you could probably just do this:

Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT `date` FROM (`Store_Information` LEFT JOIN `Internet_Sales` USING(`date`));
  2.  

----------

hi pbmods,

Thank you - will try with this...

bzb...
bzb bzb is offline
Newbie
 
Join Date: May 2007
Posts: 3
#4: Jun 1 '07

re: Alternate for INTERSECT in mysql 4.1.15


Quote:

Originally Posted by bzb

----------

hi pbmods,

Thank you - will try with this...

bzb...

=#=#==#=#==#=#==#=#==#=#=

hi pbmods,

I solved the problem by using SELF JOIN and INNER JOIN in the same query.
Thanks.


bzb...
Reply