Scooby08 Posted March 12, 2010 Share Posted March 12, 2010 I have been searching around and found that to select all columns from the database table that aren't empty I would need to use a query like so: SELECT * FROM table WHERE column IS NOT NULL It's not working out for me.. Shouldn't that do the trick? Link to comment https://forums.phpfreaks.com/topic/194992-selecting-only-table-columns-that-arent-empty/ Share on other sites More sharing options...
Adam Posted March 12, 2010 Share Posted March 12, 2010 That would depend entirely upon your table structure. Link to comment https://forums.phpfreaks.com/topic/194992-selecting-only-table-columns-that-arent-empty/#findComment-1025119 Share on other sites More sharing options...
Scooby08 Posted March 12, 2010 Author Share Posted March 12, 2010 Will this help? CREATE TABLE `table` ( `id` int(30) unsigned NOT NULL auto_increment, `column` varchar(10) NOT NULL default '', PRIMARY KEY (`id`) ) This also seems to work: SELECT * FROM table WHERE column != '' Do you see any problems with that? Link to comment https://forums.phpfreaks.com/topic/194992-selecting-only-table-columns-that-arent-empty/#findComment-1025120 Share on other sites More sharing options...
Adam Posted March 12, 2010 Share Posted March 12, 2010 That's because NULL != an empty string. In your database structure you have `column` set up as "NOT NULL", which means it cannot take NULL values. So in essence everything in that column will be NOT NULL. Link to comment https://forums.phpfreaks.com/topic/194992-selecting-only-table-columns-that-arent-empty/#findComment-1025132 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.