skip to Main Content

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'

2

Answers


  1. 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')
    
    Login or Signup to reply.
  2. 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')
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search