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 Quote 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());' ?> Quote 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. Quote 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. Quote 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 Quote 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 ('', ' ') Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/70511-solved-if-in-mysql/#findComment-354273 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.