Mysql Select Query problem
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?
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'
)
精彩评论