manalnor Posted March 29, 2011 Share Posted March 29, 2011 Hello friends, Can you help me as always. let say we have database table (id,user,name,code) and i'm gonna say MYSQL $qry="select * from table order by id desc"; Now how to say select from table where (user) is not empty and (code) is not 'something' i did tried this $qry="select * from table where user IS NOT NULL AND code IS NOT LIKE 'something' order by id desc"; but didn't work so how to say it and where i could learn such mysql commands cause i know it only in php like x == y and x != y ..ect thanks Quote Link to comment https://forums.phpfreaks.com/topic/232077-how-to-say-it/ Share on other sites More sharing options...
Maq Posted March 29, 2011 Share Posted March 29, 2011 If you want to exclude an exact value then use: AND code != 'something' EDIT: Also, I'm not sure what your default value is (assume it's NULL) but you may want to check for an empty string as well. AND user != '' Quote Link to comment https://forums.phpfreaks.com/topic/232077-how-to-say-it/#findComment-1193762 Share on other sites More sharing options...
manalnor Posted March 29, 2011 Author Share Posted March 29, 2011 thank you so much i did understood how it works both user != '' and code != 'something' works perfect shokran شكراً = thanks Quote Link to comment https://forums.phpfreaks.com/topic/232077-how-to-say-it/#findComment-1193766 Share on other sites More sharing options...
Maq Posted March 29, 2011 Share Posted March 29, 2011 shokran شكراً = thanks Heh, I actually knew that, my buddy is Lebanese You're welcome. Quote Link to comment https://forums.phpfreaks.com/topic/232077-how-to-say-it/#findComment-1193771 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.