I want to write a value into a column “email_new”, but only if this value does not exist in a second column called “email”. This means none of the entries in the column email should contain the new mail-address.
This is for a programm to change the email-address, where the email-address has to be verified, and the column “email” allows only UNIQUE values.
"
UPDATE `table`
SET email_new = '".mysql_real_escape_string($newmail)."'
WHERE
user = '".mysql_real_escape_string($user)."'
&& email NOT CONTAINS('".mysql_real_escape_string($newmail)."')
"
Is something like that possible?
you are not checking wheter the newmail is really unique:
append to your query another AND condition, something like:
AND 0 = (select count(*) from table where email = mysql_real_escape_string($newmail))