Jump to content

SQL innerjoin 3 tables with different PRIMARY keys


runnerjp

Recommended Posts

I am trying to join 3 tables together using the following sql command:



SELECT
tg.Kickoff,
tg.League,
tg.home,
tg.away,
ln.Full,
ln.Mysite,
ln.Country,
tl.mydb
FROM `todaysgames` AS tg
INNER JOIN `leaguenames` AS ln ON tg.League = ln.Othersites
INNER JOIN `teamlookup` AS tl ON tg.home = tl.websitedb
OR tg.away = tl.websitedb;

The issue is I get is it doubles each row.


What I am looking to do is for each tg.home and tg.away is replace it with the tl.websitedb (this basically amends the name).


would this be possible? (Below is the current output)


 


Capture.JPG


 


And here is the desired output


Capture2.jpg

Edited by runnerjp
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.