MYSQL 将两列与一列连接并获取数据

发布于 2024-12-25 13:29:46 字数 710 浏览 0 评论 0原文

固定的!抱歉浪费了大家的时间 :P

我试图在 PHP 中使用 mysql 将两列与一列连接起来

$result = $link->query('选择软件。*, 
流派.Naam AS 流派, 
Console.Naam AS ConsoleNaam,
Draager.Naam AS MediumNaam,
工作室.Naam AS StudioNaam,
Publisher.Naam AS PublisherNaam
来自软件
INNER JOIN 流派 ON Genre.Genre_ID = Software.Genre_ID
INNER JOIN Console ON Console.Console_ID = Software.Console_ID
内部连接 ​​Draager ON Draager.Draager_ID = Software.Medium_ID
INNER JOIN 公司 AS Studio ON Software.Studio_ID = Studio.Company_ID
INNER JOIN 公司 AS 发布者 ON Software.Publisher_ID = Publisher.Company_ID
');

Table Company 必须在 ID 上与 Table Software 合作才能获得 公司名称。

关于我必须对上面的脚本进行哪些更改才能实现的任何提示 工作?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

奢望 2025-01-01 13:29:46

只是为了得到一个答案:

关联表时 JION 拼写为 JOIN :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
');

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
');
落墨 2025-01-01 13:29:46

你有一个错字。 JOIN 拼写错误为 JION

$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
/* Misspelled JOIN below *(/
INNER JOIN Company AS Studio ON Software.Studio_ID = Studio.Company_ID
INNER JOIN Company AS Publisher ON Software.Publisher_ID = Publisher.Company_ID
');

You have a typo. JOIN misspelled as JION:

$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
/* Misspelled JOIN below *(/
INNER JOIN Company AS Studio ON Software.Studio_ID = Studio.Company_ID
INNER JOIN Company AS Publisher ON Software.Publisher_ID = Publisher.Company_ID
');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文