我有一個mysql查詢的問題。SQL INSERT WITH JOIN
這是我的2個表:
player_locations:
ID | playerid | type | location
---|-----------------------
和users:
ID | playername | [..]
----|--------------------
1 | example1 | ...
我要插入player_locations
如下:
ID | playerid | type | location
---|-----------------------
1 | 1 | 5 | DOWNTOWN
而這就是我的查詢:
INSERT INTO player_locations (id, type, location)
SELECT u1.ID as playerid,
d.type,
d2.location
FROM users u1
INNER JOIN users u2
ON 1 = 1
INNER JOIN (SELECT 5 as type
FROM DUAL) d
INNER JOIN (SELECT "DOWNTOWN" as location
FROM DUAL) d2
ON 1 = 1
WHERE u1.playername = "example1";
但是,當我在users
有6排它player_locations
你的問題與'java'(標記刪除)有什麼關係? – Pshemo
我將在java中使用查詢。我想我應該提到它。 – magl1te