Jump to content

mysql views


claro

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.