jakebur01 Posted May 17, 2007 Share Posted May 17, 2007 Hey, I have some rows in my mysql table that have blank fields as part numbers. I want to delete all of the rows that have blank part numbers. would it be like: delete from table where partnumber = '0'; ??? Quote Link to comment https://forums.phpfreaks.com/topic/51874-solved-deleting-blank-rows/ Share on other sites More sharing options...
Lumio Posted May 17, 2007 Share Posted May 17, 2007 try it Quote Link to comment https://forums.phpfreaks.com/topic/51874-solved-deleting-blank-rows/#findComment-255673 Share on other sites More sharing options...
jakebur01 Posted May 17, 2007 Author Share Posted May 17, 2007 dude I would but I have like 80,000 rows of product and I don't need to risk screwing anything up. Quote Link to comment https://forums.phpfreaks.com/topic/51874-solved-deleting-blank-rows/#findComment-255675 Share on other sites More sharing options...
phast1 Posted May 17, 2007 Share Posted May 17, 2007 It depends on the type of field and the current value for "blank" rows.. Look at the data in your table and see what value is in the part number field and use that in your delete statement.. If the field is really blank, then you would probably use: delete from table where partnumber = ''; Or, if that field has NULL values for the blank ones, then you would use: delete from table where partnumber = NULL; Quote Link to comment https://forums.phpfreaks.com/topic/51874-solved-deleting-blank-rows/#findComment-255680 Share on other sites More sharing options...
jakebur01 Posted May 17, 2007 Author Share Posted May 17, 2007 I appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/51874-solved-deleting-blank-rows/#findComment-255682 Share on other sites More sharing options...
phast1 Posted May 17, 2007 Share Posted May 17, 2007 ALWAYS MAKE A BACKUP OF YOUR DATA BEFORE TRYING ANYTHING!! I think there is also a way to run a query in test mode in order to see what the result would be without actually doing it, but I can't remember how off the top of my head.. Quote Link to comment https://forums.phpfreaks.com/topic/51874-solved-deleting-blank-rows/#findComment-255683 Share on other sites More sharing options...
pocobueno1388 Posted May 17, 2007 Share Posted May 17, 2007 Try this: mysql_query("DELETE table WHERE partnumber = '' "); Why don't you make a select statement that finds all the blank rows and print them out to make sure the delete query will be safe to do? $sql = mysql_query("SELECT * FROM table WHERE partnumber="" "); while ($row = mysql_fetch_assoc($sql)){ echo $row['col'].'<br>'; } Quote Link to comment https://forums.phpfreaks.com/topic/51874-solved-deleting-blank-rows/#findComment-255685 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.