papaface Posted September 24, 2007 Share Posted September 24, 2007 Hello, In an if statement we use if ($i != 0)... But what is the syntax if I want to find all records in a column in a table that dont equal 0 for example? Thanks Link to comment https://forums.phpfreaks.com/topic/70511-solved-if-in-mysql/ Share on other sites More sharing options...
pocobueno1388 Posted September 24, 2007 Share Posted September 24, 2007 <?php $query = "SELECT * FROM table WHERE col != 0"; $result = mysql_query($query)or die(mysql_error());' ?> Link to comment https://forums.phpfreaks.com/topic/70511-solved-if-in-mysql/#findComment-354188 Share on other sites More sharing options...
papaface Posted September 24, 2007 Author Share Posted September 24, 2007 In my case this doesnt seem to work: AND paypal != "" Im trying to find values that do not equal "" or " " in the paypal column. Link to comment https://forums.phpfreaks.com/topic/70511-solved-if-in-mysql/#findComment-354191 Share on other sites More sharing options...
roopurt18 Posted September 24, 2007 Share Posted September 24, 2007 AND LENGTH(paypal) > 0 By the way, strings in SQL are written with single quotes, not double, unless I'm mistaken. Link to comment https://forums.phpfreaks.com/topic/70511-solved-if-in-mysql/#findComment-354195 Share on other sites More sharing options...
papaface Posted September 24, 2007 Author Share Posted September 24, 2007 They can be written with either, it doesnt make a difference. Thanks that worked Link to comment https://forums.phpfreaks.com/topic/70511-solved-if-in-mysql/#findComment-354206 Share on other sites More sharing options...
Barand Posted September 24, 2007 Share Posted September 24, 2007 or you could have WHERE paypal <> '' AND paypal <> ' ' or WHERE paypal NOT IN ('', ' ') Link to comment https://forums.phpfreaks.com/topic/70511-solved-if-in-mysql/#findComment-354213 Share on other sites More sharing options...
papaface Posted September 24, 2007 Author Share Posted September 24, 2007 Thanks Link to comment https://forums.phpfreaks.com/topic/70511-solved-if-in-mysql/#findComment-354273 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.