Jump to content

Why Won't This Query Work ?


vincej

Recommended Posts

Hi - I feel like I have tried everything. I am trying to do a search of my customer and orders tables where I allow search terms including "email". It works fine when I only search for "telephone" or "name" but it will not find customer by "email". What is even more bizaar is that it does work perfectly when I run it locally on my Xampp server. But when I upload it to my ISP it just will not find "email".

 

 

SELECT customerid, order.orderid,order.status,order.pickupdate,customer.firstname,customer.lastname,customer.address,customer.phonenumber,customer.cellphone,customer.email,customer.id
 FROM `order` 
 inner JOIN `customer`
 ON  customer.id = customerid
 WHERE order.status = 'open'
 AND lastname LIKE '$term%'
 OR PhoneNumber LIKE '$term%'
 OR customer.email LIKE '$term%
 GROUP BY order.pickupdate
 ORDER BY order.customerid ASC

 

 

any thoughts ??

 

Many Thanks !!

Link to comment
https://forums.phpfreaks.com/topic/271053-why-wont-this-query-work/
Share on other sites

Use (..) when mixing AND and OR

 

SELECT customerid, order.orderid,order.status,order.pickupdate,customer.firstname,customer.lastname,customer.address,customer.phonenumber,customer.cellphone,customer.email,customer.id
FROM `order`
inner JOIN `customer`
ON customer.id = customerid
WHERE order.status = 'open'
AND
(
lastname LIKE '$term%'
OR PhoneNumber LIKE '$term%'
OR customer.email LIKE '$term%'
)
GROUP BY order.pickupdate
ORDER BY order.customerid ASC

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.