數據庫1(2個表):sandbox_maesc4加入來自兩個不同數據庫的3個表?
表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」字段的關係連接起來,將「座標」和「userlogged」兩個表結合起來。我怎樣才能做到這一點?以下是我嘗試過的查詢,但不起作用。
我在「座標」表(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
究竟沒有工作? – pancho018 2014-10-27 16:01:40
該查詢不選擇我想要顯示的字段 – mario 2014-10-27 16:16:59