0

私は以下のクエリを使用しています:

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

そしてそれは私に次のようなエラーを与えます:#1054 - Unknown column 'Nisha' in 'where clause'

Yそうですか?誰かがこれを解決するために私を導くことができますか?

4

1 に答える 1

6

Nishaを引用符で囲む必要があるようです。'Nisha'

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

AND/ORさらに、このエラーとは関係ありませんが、条件のWHERE条件を括弧内にグループ化する必要があることに注意してください。

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'
      )
于 2010-06-25T13:10:35.230 に答える