Trying to do the following:
Select fields "user_from, username, user_email FROM database phpusers where user_from does NOT contain "USA" nor are BLANK, and then order by username.
My PHP script is :
$sql = "SELECT user_from, username, user_email FROM phpbb_users WHERE user_from NOT LIKE '%usa%' OR user_from=NULL OR user_from='' ORDER BY username";
//Execute SQL query
$sql_result = mysql_query($sql,$conn) or die(mysql_error());
It seems to be selecting all those without "USA" which is what I want, however seems to be ignoring the part about NOT wanting to select those that are BLANK (NULL).
Help. Thanks
php/mysql - want to select all NOT NULL, not work right..
Moderator: General Moderators
-
camarosource
- Forum Commoner
- Posts: 77
- Joined: Sat Aug 03, 2002 10:43 pm
Code: Select all
SELECT * FROM phpbb_users WHERE user_from != 'usa' OR user_from != NULL OR user_from != '' ORDER BY usernamethat should work
-
camarosource
- Forum Commoner
- Posts: 77
- Joined: Sat Aug 03, 2002 10:43 pm
- andre_c
- Forum Contributor
- Posts: 412
- Joined: Sun Feb 29, 2004 6:49 pm
- Location: Salt Lake City, Utah
instead of doing do
Code: Select all
!= NULLCode: Select all
IS NOT NULL