Search code examples
phpmysqlsqlnew-operator

MYSQL JOIN two columns with one and get data


FIXED! sorry to waste anyones time :P

im trying to get two colums joined with one with mysql in PHP

$result = $link->query('SELECT Software.*, 
Genre.Naam AS Genre, 
Console.Naam AS ConsoleNaam,
Draager.Naam AS MediumNaam,
Studio.Naam AS StudioNaam,
Publisher.Naam AS PublisherNaam
FROM Software
INNER JOIN Genre ON Genre.Genre_ID = Software.Genre_ID
INNER JOIN Console ON Console.Console_ID = Software.Console_ID
INNER JOIN Draager ON Draager.Draager_ID = Software.Medium_ID
INNER JOIN Company AS Studio ON Software.Studio_ID = Studio.Company_ID
INNER JOIN Company AS Publisher ON Software.Publisher_ID = Publisher.Company_ID
');

Table Company has to join with Table Software on there ID's to get the name of the Company.

Any tips on what i have to change to the script above to get it to work?


Solution

  • Just to have an answer:

    JION is spelled JOIN when relating tables :D

    $result = $link->query('SELECT Software.*, 
    Genre.Naam AS Genre, 
    Console.Naam AS ConsoleNaam,
    Draager.Naam AS MediumNaam,
    Studio.Naam AS StudioNaam,
    Publisher.Naam AS PublisherNaam
    FROM Software
    INNER JOIN Genre ON Genre.Genre_ID = Software.Genre_ID
    INNER JOIN Console ON Console.Console_ID = Software.Console_ID
    INNER JOIN Draager ON Draager.Draager_ID = Software.Medium_ID
    INNER JOIN Company AS Studio ON Software.Studio_ID = Studio.Company_ID
    INNER JOIN Company AS Publisher ON Software.Publisher_ID = Publisher.Company_ID
    ');