jakebur01 Posted February 25, 2009 Share Posted February 25, 2009 I am trying to delete all the rows that do not have a value. The fields were originally formated in excel - accounting with 2 decimal places. Is there a better way to get rid of all of the rows that do not have valid prices? mysql_query("DELETE FROM {$tablename} WHERE $dealer=''"); mysql_query("DELETE FROM {$tablename} WHERE $dealer='$-'"); mysql_query("DELETE FROM {$tablename} WHERE $dealer='-'"); mysql_query("DELETE FROM {$tablename} WHERE $dealer='$0.00'"); mysql_query("DELETE FROM {$tablename} WHERE $dealer='0'"); mysql_query("DELETE FROM {$tablename} WHERE $dealer='0.00'"); mysql_query("DELETE FROM {$tablename} WHERE $dealer='0.0'"); mysql_query("DELETE FROM {$tablename} WHERE $dealer='$0.0'"); Quote Link to comment Share on other sites More sharing options...
premiso Posted February 25, 2009 Share Posted February 25, 2009 You could just use the IN statement and have 1 query: mysql_query("DELETE FROM {$tablename} WHERE $dealer IN('', '$-')"); Just add the rest to that IN statement following the same format. Quote Link to comment Share on other sites More sharing options...
jakebur01 Posted February 25, 2009 Author Share Posted February 25, 2009 Cool, thanks. Quote Link to comment Share on other sites More sharing options...
Lodius2000 Posted February 25, 2009 Share Posted February 25, 2009 if you used mysqli or a some of the dba's out there you could use a prepared statement, run it through a foreach and do it all with the same query // this method still makes multiple db queries though Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.