JSHINER Posted June 6, 2007 Share Posted June 6, 2007 I have this: "SELECT count(*) FROM table WHERE id = 2" I would also like to add the condition that if name is NOT blank - I tried "AND name != but that did not work. How can I do this, so it only displays results where name has a value? Quote Link to comment https://forums.phpfreaks.com/topic/54443-solved-help-with-a-query/ Share on other sites More sharing options...
trq Posted June 6, 2007 Share Posted June 6, 2007 SELECT count(*) FROM table WHERE id = 2 && name <> NULL Quote Link to comment https://forums.phpfreaks.com/topic/54443-solved-help-with-a-query/#findComment-269248 Share on other sites More sharing options...
JSHINER Posted June 6, 2007 Author Share Posted June 6, 2007 That does not return any results. When I did: SELECT * FROM table WHERE id = 2 AND field_2 ORDER BY id It returns only records where field_2 is filled, however ONLY records where field 2 is filled with a number. How can I get it so if field_2 has ANYTHING there it returns it? Quote Link to comment https://forums.phpfreaks.com/topic/54443-solved-help-with-a-query/#findComment-269277 Share on other sites More sharing options...
JSHINER Posted June 6, 2007 Author Share Posted June 6, 2007 Sorry - Figured it out. SELECT * FROM table WHERE id = 2 AND field_2 != '' ORDER BY id Quote Link to comment https://forums.phpfreaks.com/topic/54443-solved-help-with-a-query/#findComment-269279 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.