Connecting Tech Pros Worldwide Forums | Help | Site Map

WHERE colum1 = (SELECT with multiple results)

Newbie
 
Join Date: Oct 2008
Posts: 1
#1: Oct 10 '08
Hi I have a problem with a WHERE clause, I have to compare a column value to a query that returns multiple results, I also tried to substitute the "=" for "IN" but didn't worked.
Any help would be apreciated: D

Delerna's Avatar
Expert
 
Join Date: Jan 2008
Location: Sydney
Posts: 790
#2: Oct 11 '08

re: WHERE colum1 = (SELECT with multiple results)


You could try something like this
Expand|Select|Wrap|Line Numbers
  1. SELECT field list
  2. FROM YourTable
  3. join (   SELECT TheMultipleResultField 
  4.           FROM TheRecordSource
  5.           WHERE YourFilterRequirements
  6. ) a on column1=TheMultipleResultField
  7.  
here, the join will filter out the rows that don't have matching
records in the subquery.
ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,925
#3: Oct 12 '08

re: WHERE colum1 = (SELECT with multiple results)


Be careful with IN, it does not work well with NULL values.

I got some notes about that here

-- CK
Reply