duckxtales Posted February 28, 2007 Share Posted February 28, 2007 I have the following code and I'm having trouble doing a query where it looks up the DB to see if the email exsist, but it should bypass a specific email. Is there an except syntax where I can use to do a query to select * where email = $email except where email = '[email protected]'; ? $results = $aQuery -> query("SELECT * FROM affiliates WHERE email = '$Email'"); $duplicatex = mysql_num_rows($results); $duplicatexArray = mysql_fetch_array($results); $atsign = substr_count($Email, '@'); if($duplicatex > 1) die("ERROR, MORE THAN 1 EMAIL HAS BEEN DETECTED. PLEASE REPORT TO ADMIN."); Link to comment https://forums.phpfreaks.com/topic/40495-mysql-query-to-select-except-for-1/ Share on other sites More sharing options...
r-it Posted February 28, 2007 Share Posted February 28, 2007 select * from table where email <> '$email' Link to comment https://forums.phpfreaks.com/topic/40495-mysql-query-to-select-except-for-1/#findComment-195900 Share on other sites More sharing options...
ToonMariner Posted February 28, 2007 Share Posted February 28, 2007 As you set the value of $email that goes into the query then simply do not set it to the email you wish to be ignored by the query. If this is a user entering an email address to check if its listed then $results = $aQuery -> query("SELECT * FROM affiliates WHERE email = '$Email' AND email != '[email protected]'"); Will ensure that no results are returned... Or you could save yourself a query and do this.. if (strcasecmp('[email protected]', $email) == 0) { echo "NO RESULTS"; } else { $results = $aQuery -> query("SELECT * FROM affiliates WHERE email = '$Email'"); $duplicatex = mysql_num_rows($results); $duplicatexArray = mysql_fetch_array($results); $atsign = substr_count($Email, '@'); if($duplicatex > 1) die("ERROR, MORE THAN 1 EMAIL HAS BEEN DETECTED. PLEASE REPORT TO ADMIN."); } Link to comment https://forums.phpfreaks.com/topic/40495-mysql-query-to-select-except-for-1/#findComment-195902 Share on other sites More sharing options...
r-it Posted February 28, 2007 Share Posted February 28, 2007 my bad, i forgot the syntax for not equal in mysql is != and not <>, but its the same principle Link to comment https://forums.phpfreaks.com/topic/40495-mysql-query-to-select-except-for-1/#findComment-195905 Share on other sites More sharing options...
itsmeArry Posted February 28, 2007 Share Posted February 28, 2007 SELECT * FROM affiliates WHERE email = '$Email' and email <> "[email protected]" Link to comment https://forums.phpfreaks.com/topic/40495-mysql-query-to-select-except-for-1/#findComment-195920 Share on other sites More sharing options...
itsmeArry Posted February 28, 2007 Share Posted February 28, 2007 both will work either you use != or <> in mysql Link to comment https://forums.phpfreaks.com/topic/40495-mysql-query-to-select-except-for-1/#findComment-195931 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.