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??

3
  • you should add your table schema, some sample data and your expected results Commented May 18, 2015 at 1: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? Commented May 18, 2015 at 1:21
  • Are there any errors? Commented May 18, 2015 at 1:36

1 Answer 1

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);
Sign up to request clarification or add additional context in comments.

1 Comment

looks very promising... gonna code it up and let you know. Thanks for posting :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.