Jump to content

Using Multiple Tables.


bobicles2

Recommended Posts

Typically you'll use a join for that, though you can use a subquery.  Most SQL tutorials will cover that.  Are you definitely using postgres and not mysql?

 

Eerm...the report its for says

 

"The implementation should include appropriate use of the advanced features of PostgreSQL"

 

But ive just implemented the tables using phpmyadmin? so im not 100% of the differences? perhaps this could be something i may need to learn more about?

 

Link to comment
Share on other sites

Aha .. if they're asking you to use postgresql, then you can't be using phpmyadmin.  That's for the more common database package called Mysql.

 

Judging by the wording, this is a report you are doing for a class?  In which case your teacher should be able to tell you how you're expected to get access to Postgresql to complete it.

 

It's difficult for me to comment more as I'm not sure how you're supposed to be accessing postgresql, and I'm not sure what features are considered "advanced" :)  Possibly a join is considered advanced if it's a basic database class.  Join basically means "Match table 1 and table 2 up wherever column a from table 1 matches column b from table 2".  It can get more complex but that's the basic meaning.  In your case you want to match the GP column from Patient table with the ID column from GP table, probably.

 

You can write it as F1Fan wrote it above, or here's an alternative:

 

SELECT *
FROM Patient
JOIN GP ON (Patient.GP = GP.ID)

 

Here I'm using "*" instead of listing columns, and I'm using another syntax for joins, which I find easier to understand.  And I'm not aliasing the tables.

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.