Jump to content

[SOLVED] Joining SQLs together


otuatail

Recommended Posts

Can someone tell me how to extract records that I need for a mailing list. The first 3 are easy the last I can’t work out.

I need to recover any records that have dropped out of the system because of an invalid entry

Select * from Customers where Age < 21;

Select * from Customers where UK = true;

Select * from Customers where Special_Delivery = true ;

 

There could be a lot of queries. I need one that recovers all the remaining like

 

Select  * from Customers where where ..... Not covered by SQL1 ,SQL2 , SQL3

 

It would mean adding queries together.

 

TIA

 

Desmond.

 

 

Link to comment
Share on other sites

Yes this would work but I might have to extend it. I thought I could copy a query inside another query. I have seen queries before with multipul SELECT statments in them like

 

WHERE (SELECT  * FROM ...)

 

The above could get very messy!

 

I don't think so. Using subqueries for such simple task would actually be even more messy

 

WHERE
Customers.ID NOT IN (SELECT ID FROM Customers WHERE Age < 21)
OR
  Customers.ID NOT IN (SELECT ID FROM Customers WHERE UK = true)
OR
  Customers.ID NOT IN (SELECT ID FROM Customers WHERE Special_Delivery = true)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.