claro Posted October 11, 2011 Share Posted October 11, 2011 Hello folks, good day! I'm having trouble here selecting my desired data. I hope somebody will help me. Im having two tables. tbl_a seId course year 1 IT 1999 2 HE 1992 3 RT 1990 tbl_b id seId status 1 1 NO 2 2 YES I want to select A.*,B.* from tbl_a AS A, tbl_b AS B having status = NO and status IS NULL my desired output is to see the following. course year status IT 1999 NO RT 1990 is it possible? thank you in advance. Link to comment https://forums.phpfreaks.com/topic/248864-mysql-views/ Share on other sites More sharing options...
MasterACE14 Posted October 11, 2011 Share Posted October 11, 2011 SELECT `tbl_a`.* AS A, `tbl_b`.* AS B FROM `tbl_a`,`tbl_b` WHERE B.`status`='NO' OR B.`status` IS NULL; Link to comment https://forums.phpfreaks.com/topic/248864-mysql-views/#findComment-1278006 Share on other sites More sharing options...
claro Posted October 11, 2011 Author Share Posted October 11, 2011 what if status I want to view is any word except for yes. ? Link to comment https://forums.phpfreaks.com/topic/248864-mysql-views/#findComment-1278007 Share on other sites More sharing options...
awjudd Posted October 11, 2011 Share Posted October 11, 2011 SELECT `tbl_a`.* AS A, `tbl_b`.* AS B FROM `tbl_a`,`tbl_b` WHERE B.`status`<> 'YES' OR B.`status` IS NULL; ~juddster Link to comment https://forums.phpfreaks.com/topic/248864-mysql-views/#findComment-1278009 Share on other sites More sharing options...
claro Posted October 11, 2011 Author Share Posted October 11, 2011 is null and empty row the same? I just want to make sure that my question is clear. Thank you for your response by the way but t shows only data that contains status <> YEs. is there any way to show the null ? Link to comment https://forums.phpfreaks.com/topic/248864-mysql-views/#findComment-1278010 Share on other sites More sharing options...
codefossa Posted October 11, 2011 Share Posted October 11, 2011 is null and empty row the same? I just want to make sure that my question is clear. Thank you for your response by the way but t shows only data that contains status <> YEs. is there any way to show the null ? Not without showing the status fields that are 'YES', or a nullified status field. SELECT `course`, `year`, `status` FROM `tbl_a` `a` LEFT JOIN (SELECT `status`, `seId` FROM `tbl_b` WHERE `status` != 'YES') AS `b` ON `a`.`seId` = `b`.`seId` That will show all three fields, and a nulled status field for the second one, but if you do a right join, it would only show the first field because the third is null. The same goes for regular join and inner join. Link to comment https://forums.phpfreaks.com/topic/248864-mysql-views/#findComment-1278011 Share on other sites More sharing options...
claro Posted October 11, 2011 Author Share Posted October 11, 2011 The law of everything: Garbage in, Garbage out. If you don't give us enough information to help you the correct way, the results won't end up being correct. If your qoute is a gun, I'm dead. I'm really thankful for your time. attached is my real table. I want is to show all files from tbl_user, tbl_studenroll and status <> YES [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/248864-mysql-views/#findComment-1278023 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.