how would i do this in correct syntax :
"SELECT * FROM comm_en WHERE client_id='$client_id' AND tmp!=''"
basically it's looking for non-empty fields
thanks
Some thing like... "SELECT * FROM comm_en WHERE client_id='$client_id' AND tmp NOT LIKE '%whatever%'"
This is what is used in a search, The LIKE and the % round the word will not select any row (tmp column) that contains the word whatever even if it is in the middle of a sentence.
Perhaps you are looking to write:
SELECT * FROM comm_en WHERE client_id='$client_id' AND tmp<>''
so if i did
"SELECT * FROM comm_en WHERE client_id='$client_id' AND tmp NOT LIKE ''"
then it should return all rows that are not like nothing - therefore must contain something ?? or am i barking up the wrong tree ?
laserlight wrote:Perhaps you are looking to write: SELECT * FROM comm_en WHERE client_id='$client_id' AND tmp<>''
i might be but i've never seen that one before - does <> mean 'nothing' ?
It means "not equal to". I had the impression that != should also work though, but maybe that is SQL dialect specific.
i think you're right - I just tried again with != and it worked this time ....
when i tried that before I got a message saying i had a syntax error near !=
i assumed that was the problem but maybe it was something else
thanks anyway for your help
<>
is standard SQL.
!=
is a vendor specific extension.
it works in sql for me im using mysqli though, SELCT * FROM table WHERE acc!='admin'
table
acc
works for me
it works in sql for me im using mysqli though,
The MySQLi extension does not matter here. Lars Berg's point is that != is an language extension to standard SQL for MySQL and possibly some other SQL dialects.