我有一个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