Adding another table to this sql statement

I currently have this sql statement to join the three tables with the players identifier, but I would like to change this so that I can also join the playerdetails table. Below i

"SELECT technicaldetails.*,
                            mentaldetails.*,
                            physicaldetails.*
                    FROM    PlayerDetails
                    INNER JOIN mentaldetails ON mentaldetails.PlayerId = playerdetails.PlayerId 
                    INNER JOIN technicaldetails ON technicaldetails.PlayerId = playerdetails.PlayerId
                    INNER JOIN physicaldetails ON physicaldetails.PlayerId = playerdetails.PlayerId                       
                    WHERE playerdetails.playerID = " & DetailsPlayerID & ";"

PlayerDetails Table

PlayerID | FirstName | Lastname
-------------------------------
1        | John      | Smith

And the details tables look similar to this

PlayerID | Corners | Crossing | BallControl|ect...
-------------------------------------------
1        | 15      | 13       | 19
+4
source share
2 answers

You can use the below request.

 SELECT technicaldetails.*, mentaldetails.*, physicaldetails.*,
 detailtable.* FROM PlayerDetails
 INNER JOIN mentaldetails ON mentaldetails.PlayerId =playerdetails.PlayerId 
 INNER JOIN technicaldetails ON technicaldetails.PlayerId = playerdetails.PlayerId
 INNER JOIN physicaldetails ON physicaldetails.PlayerId = playerdetails.PlayerId  
 left join detailtable on physicaldetails.PlayerId = detailtable.PlayerId                     
 WHERE playerdetails.playerID = " & DetailsPlayerID & ";
0
source

What you need is as simple as adding new selected columns. Your actual request begins with

SELECT 
    technicaldetails.*,
    mentaldetails.*,
    physicaldetails.*
FROM
    PlayerDetails
    INNER JOIN mentaldetails ON ...
    INNER JOIN technicaldetails ON ...
    INNER JOIN physicaldetails ON ...
WHERE
    ...

, SQL, (*) technicaldetails, mentaldetails physicaldetails. PlayerDetails FROM, , , SELECT.

SELECT
    PlayerDetails.*,
    technicaldetails.*,
    mentaldetails.*,
    physicaldetails.*
FROM
    PlayerDetails
    INNER JOIN mentaldetails ON ...
    INNER JOIN technicaldetails ON ...
    INNER JOIN physicaldetails ON ...
WHERE
    ...

:

"SELECT 
    PlayerDetails.*,
    technicaldetails.*,
    mentaldetails.*,
    physicaldetails.*
FROM    
    PlayerDetails
    INNER JOIN mentaldetails ON mentaldetails.PlayerId = playerdetails.PlayerId 
    INNER JOIN technicaldetails ON technicaldetails.PlayerId = playerdetails.PlayerId
    INNER JOIN physicaldetails ON physicaldetails.PlayerId = playerdetails.PlayerId                       
WHERE 
    playerdetails.playerID = " & DetailsPlayerID & ";"

WHERE, .

"SELECT 
    PlayerDetails.*,
    technicaldetails.*,
    mentaldetails.*,
    physicaldetails.*
FROM    
    PlayerDetails
    INNER JOIN mentaldetails ON mentaldetails.PlayerId = playerdetails.PlayerId 
    INNER JOIN technicaldetails ON technicaldetails.PlayerId = playerdetails.PlayerId
    INNER JOIN physicaldetails ON physicaldetails.PlayerId = playerdetails.PlayerId ;"                       
0

Source: https://habr.com/ru/post/1695443/


All Articles