0

Hi and thanks for reading.

SELECT DISTINCT (thisID and thisNAME) from table1 WHERE thisID IN
(SELECT id from table2 WHERE ... condtions)
OR 
(SELECT id from table3 WHERE ... different condtions)
OR 
(SELECT id from table99 WHERE ...even more conditions)

I need to perform a few SELECTS to provide a nu,ber of thisID's once I have these I need to select only thethisID and thisNAME from the table 1.

I must admit Im a little out of my depth with writing queries...but Im certain Im on the right lines? Any help please??

Will
  • 389
  • 1
  • 11
  • you should add your table schema, some sample data and your expected results – pala_ May 18 '15 at 01:19
  • im simply looking for the correct syntax in building the actual query. The rest I can work out. Which bit of the question would you need ellaborating to help? – Will May 18 '15 at 01:21
  • Are there any errors? – Ajoy May 18 '15 at 01:36

1 Answers1

3

Your SQL is pretty close. You need to repeat the IN part and fix a few outher syntactic stuff:

SELECT DISTINCT thisID, thisNAME
from table1
WHERE thisID IN (SELECT id from table2 WHERE ... conditions) OR 
      thisID IN (SELECT id from table3 WHERE ... different conditions) OR
      thisID IN (SELECT id from table99 WHERE ...even more conditions);
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786