Jump to content

Table join question


elmpp

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:

 

http://www.freecaradverts.com/red_snapper_test.pdf

 

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!!!!!!!!!!!!

:x

Link to comment
https://forums.phpfreaks.com/topic/1060-table-join-question/
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?

Link to comment
https://forums.phpfreaks.com/topic/1060-table-join-question/#findComment-3608
Share on other sites

Archived

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

×
×
  • 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.