Zephni Posted September 2, 2011 Share Posted September 2, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/246283-understanding-join/ Share on other sites More sharing options...
AyKay47 Posted September 2, 2011 Share Posted September 2, 2011 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.. Quote Link to comment https://forums.phpfreaks.com/topic/246283-understanding-join/#findComment-1264759 Share on other sites More sharing options...
Zephni Posted September 2, 2011 Author Share Posted September 2, 2011 I just looked at "the" sticky for MYSQL and the top website helped: http://www.sqlzoo.net/3b.htm , I think I just needed to actualy do it and practise to understand it a little better. Sorry for posting I should of done that first Quote Link to comment https://forums.phpfreaks.com/topic/246283-understanding-join/#findComment-1264768 Share on other sites More sharing options...
AyKay47 Posted September 2, 2011 Share Posted September 2, 2011 well hopefully my post helped you as well.. Quote Link to comment https://forums.phpfreaks.com/topic/246283-understanding-join/#findComment-1264775 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.