I have an OsCommerce store and wanted to modify a customer lookup query to include the delivery address postcode so that i can search for a customer based on his delivery postcode which might be different to his normal home address postcode.
The original query is as follows:-
but i want to include another lookup of delivery_postcode which is in the orders table, the common field for all tables is customers_id (although there may be more than one order in the orders table for the same customers_id)
select a.entry_company, c.customers_id, c.customers_lastname, c.customers_telephone, c.customers_mobile_number, c.customers_firstname, c.customers_email_address, a.entry_country_id,a.entry_city,a.entry_state from customers c left join address_book a on c.customers_id = a.customers_id and c.customers_default_address_id = a.address_book_id where a.entry_postcode like '%EX8 2NX%' OR a.entry_postcode like '%EX82NX%' and 1 order by c.customers_id DESC
I need to add something like the following to the query and a join to the orders table:-
any help appreciated as joins are beyond my meagre sql skills
OR o.delivery_postcode like '%EX8 2NX%' OR o.delivery_postcode like '%EX82NX%'