I've been trying to get my head around how to use a single query to select data from two of my tables. If anybody can suggest a better way than a single query, I'm all ears! Previously I would do this using two queries which I could make work easily although I'm led to believe that a single query would be better, hence trying to learn.
One of my tables resembles this in a cut down form. Call this table "member":
ID | firstName | lastName | networkingID
And the other table which I'll call "networking":
ID | websiteURL | facebookURL | twitterURL
What I'm trying to do is run a query on the table member like:
SELECT * FROM `member` WHERE `ID`=2
Which returns the data from the table member.
However I also wish to return the relating value from the table networking. The column networkingID in the table member is the ID of the row in networking.
How would I go about doing this?
So far, I have experimented using all of the JOINs that I was able to find through Google but I am unable to make it work. My best result was with a LEFT JOIN where all of the columns were present but the results from the networking table were all NULL.