Click to See Complete Forum and Search --> : select results from customers where customer id is present in the orders table


grumpyoldtechs
01-09-2007, 02:56 PM
SELECT orders.*, customers.* FROM orders LEFT JOIN customers ON orders.customer_id = customers.customer_id WHERE customers.$field LIKE '%$search%' ORDER BY $field ASC LIMIT $offset, $max_rows

sorry if my SQL is a mess SQL isn't my strong point. i need to select all the customers which are valid for the search in which the customer_id is present as a foreign key in the orders table.

basically only show customers which have placed orders.

grumpyoldtechs
01-09-2007, 03:23 PM
solved im using an inner join

scottrickman
01-10-2007, 04:10 PM
You can add a HAVING clause you your statement