简体   繁体   中英

Select query with “Join” is ignoring where clause

I am fetching data from two tables using query with WHERE clause. Query is working fine in local xampp but when I try to run same query in online phpmyadmin then it showing all available result(instead of filtering with WHERE clause). In other words, in online phpmyadmin , it's completing ignoring the WHERE clause like it's not even present in query, and showing all results.

Why it is not working online? Any idea?

SELECT * FROM `customers` E 
JOIN `customer plans` D ON (E.ID = D.`Cust ID`) 
WHERE E.`Email` = 'abc1002' 
OR E.`Phone` = 'abc1002' 
OR E.`Case ID` = 'abc1002' 
OR D.`Customer ID` = 'abc1002'

You can try below - using OR condition within parenthesis

SELECT * FROM `customers` E JOIN `customer plans` D 
ON (E.ID = D.`Cust ID`) 
where 
(E.`Email` = 'abc1002' OR E.`Phone` = 'abc1002' OR E.`Case ID` = 'abc1002' OR D.`Customer ID` = 'abc1002')

You can try this type of join:

select E.*,D.*
from `customers` E , `customer plans` D
where E.ID = D.`Cust ID` and
(E.`Email` = 'abc1002' OR E.`Phone` = 'abc1002' OR E.`Case ID` = 'abc1002' OR D.`Customer ID` = 'abc1002')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM