0

I am using this below given query:

SELECT o.orders_id, o.customers_name, o.customers_id, o.payment_method, o.google_order_id, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name
FROM orders o, orders_status s, customers c
WHERE o.customers_id = c.customers_id
AND o.orders_status = s.orders_status_id
AND c.customers_firstname = Nisha
OR c.customers_lastname = Nisha
OR c.customers_email_address = Nisha
OR c.customers_telephone = Nisha

and it gives me error as :#1054 - Unknown column 'Nisha' in 'where clause'

Y is it so? could some one guide me to resolve this?

1 Answer 1

6

It looks like you simply need to enclose Nisha in quotes: 'Nisha'

...
AND c.customers_firstname = 'Nisha'
OR c.customers_lastname = 'Nisha'
OR c.customers_email_address = 'Nisha'
OR c.customers_telephone = 'Nisha'

In addition, although not related to this error, note that you should probably group AND/OR conditions of the WHERE conditions in parenthesis:

WHERE (  o.customers_id = c.customers_id AND
         o.orders_status = s.orders_status_id
      ) AND
      (
         c.customers_firstname = 'Nisha' OR
         c.customers_lastname = 'Nisha' OR
         c.customers_email_address = 'Nisha' OR
         c.customers_telephone = 'Nisha'
      )
Sign up to request clarification or add additional context in comments.

Comments

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.