shah rushabh shah rushabh - 2 months ago 9
MySQL Question

MYSQL not equal '<>' not working. How to resolve it?

CODEIGNITER CODE:

$data=$this->db->query("SELECT * FROM `ads` WHERE (`UniqueID` IN ($uniqueids)) AND 'EmailAddress' <> '$email'")->result_array();


Value of $email is shahrushabh1996@gmail.com.still it appearing shahrushabh1996@gmail.com in result so which mistake I made please resolve it.

Answer

You have single quotes around the column name, so your emailaddress is compared to the string not the column value:

'EmailAddress' <> '$email'

Remove the single quotes around EmailAddress

EmailAddress <> '$email'

and it will work.