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
https://forums.phpfreaks.com/topic/180274-solved-joining-sqls-together/
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)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.