Jump to content


This topic is now archived and is closed to further replies.


Table join question

Recommended Posts

I have this question to answer as part of a job application, so i would be very grateful if i could get some help!!


The question in question is number 2c at this link:




I know this is a bit cheeky, but I\'m desparate to get this done. Is this possible within MySQL (i\'m trying it with that). I\'ve tried comparing the tables with an

 if(SUBSCRIPTION.paperid=PAPER.paperid, \'True\', \'False\') 

but can\'t seem to just get the 5 returned rows. Help!!!!!!!!!!!!


Share this post

Link to post
Share on other sites

select papername, IF(personid is null,\'False\', \'True\') as subscribed

from paper

left outer join subscription on paper.paperid=subscription.paperid

and subscription.personid =1

order by papername


The important things:


-use left outer join to get a row whether or not Jacque is subscribed

-use AND to only get rows from subscription that are Jacque (personid =1). Since a person can only be subscribed to a paper once, this means that we either get a personid of 1, or NULL in the personid column.

-use IF on personid to test for NULL (ie a paper that Jacque is not a subscriber to)



Don\'t say I never did anything for ya :wink:

Now if you get the job, will I be getting a kickback from you?

Share this post

Link to post
Share on other sites

Thanks v. much. That means my application is finished. If i get that job I\'ll...

Share this post

Link to post
Share on other sites


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.