【发布时间】:2014-10-27 15:46:12
【问题描述】:
数据库 1(2 个表):sandbox_maesc4
表1:坐标
+----------------------------------------+
|coord_id | section_name | station_number|
+----------------------------------------+
| 1 | A | A7 |
| 2 | B | B20 |
| 3 | C | C3 |
| 4 | D | D14 |
| 5 | E | E9 |
+----------------------------------------+
表 2:workstation_userlogged
+----------------------------------+
| id | ws | user |
+----------------------------------+
| 1 | COMP123 | ryan |
| 2 | COMP345 | luda |
| 3 | COMP567 | chris |
| 4 | COMP891 | michel|
| 5 | COMP444 | isabel|
+----------------------------------+
数据库 2(1 个表):softphone_materials_updater
表 1:工作站
+----------------------------+
| ID | ws | pod |
+----------------------------+
| 1 | COMP123 | A07 |
| 2 | COMP345 | B20 |
| 3 | COMP567 | C03 |
| 4 | COMP891 | D14 |
| 5 | COMP444 | E09 |
+----------------------------+
问题:
我在数据库 2 中只有读取权限。 所以我对这两个字段进行了 SELECT 查询并创建了“userlogged”表。
现在,我想通过加入表“工作站”来合并两个表“坐标”和“用户登录” 与它们的“station_number”字段和“pod”字段的关系。我怎样才能做到这一点?以下是我尝试过但不起作用的查询。
我在“坐标”表中有额外的字段(带有实际坐标的 X、Y 字段)。在 PHP 中,我使用所有字段在屏幕上显示它们。
SELECT
coordinate_id,
section_name,
x_coord,
y_coord,
ws.username,
ws.hostname,
w.pod,
FROM
sandbox_maesc4.coordinates c,
sandbox_maesc4.workstation_userlogged ws
INNER JOIN
softphone_materials_updater.workstations w
ON c.station_number = w.pod
【问题讨论】:
-
究竟是什么没用?
-
查询没有选择我要显示的字段