I have two tables:
Customers: ID, Email, Firstname, Lastname, IsSubscribed, SiteID Payments: CustomerID, PayStatus
I want to search all customers, who have elected to be on my mailing list, from a particular site and who have made a payment.
This is what I have got:
SELECT Email, Firstname, Lastname FROM Customers t1
WHERE t1.IsSubscribed='1'
AND t1.SiteID=’414’
INNER JOIN Payments t2
ON t1.ID = t2.CustomerID
WHERE PayStatus=1;
I have been using ORM for a number of years now and I have completely forgotten how to use MySQL properly...
Any guidance on how to do this correctly would be greatly appreciated!
答案 0 :(得分:1)
You can check this query:
SELECT Email, Firstname, Lastname FROM Customers t1
INNER JOIN Payments t2
ON t1.ID = t2.CustomerID
WHERE t1.IsSubscribed='1'
AND t1.SiteID=’414’
AND t2.PayStatus=1;