'What is the purpose of AND operator in SQL? How do I use AND in my query below?

SELECT 
    c.LastName, 
    c.FirstName, 
    i.InvoiceId, 
    i.CustomerId, 
    i.InvoiceDate, 
    i.BillingCity,
    i.total  
FROM 
    invoices i 
INNER JOIN 
    customers c ON i.CustomerId = c.CustomerId 
WHERE 
    BillingCity LIKE 'P%' 
    OR Billingcity NOT LIKE 'D%' 

I want to know what is the purpose of AND operator and How do I use AND in the query above to find customers from New York who have spent 10$ ?

sql


Solution 1:[1]

Use this:

SELECT 
    c.LastName, 
    c.FirstName, 
    i.InvoiceId, 
    i.CustomerId, 
    i.InvoiceDate, 
    i.BillingCity,
    i.total  
FROM 
    invoices i 
INNER JOIN 
    customers c ON i.CustomerId = c.CustomerId 
WHERE 
    i.BillingCity = 'New York' AND i.total = 10

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nayanish Damania