Jump to content

Understanding JOIN


Zephni

Recommended Posts

Hi guys, I have been using MSQL for quite some time, yet I still tend to use PHP to sort out some of my querys.. Which I know is wrong, I feel I need to understand the JOIN method a little more but can't quite get my head around it.

 

Could someone explain this query I found on w3s in english:

 

SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo
FROM Persons
INNER JOIN Orders
ON Persons.P_Id=Orders.P_Id
ORDER BY Persons.LastName

 

Thank you v much for you help

Link to comment
Share on other sites

it explains this example on the website.. which part don't you understand?

the query selects the fields lastname and firstname from the table persons.. and orderno from the table orders..now you can't reference two tables without using a join..that is what they are for.. now the condition on which theses two tables are joined is the field p_id from the table persons must be equal to the p_id field from the persons table..the resulting fields are to be ordered by the lastname field from the persons table..

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.