【发布时间】:2016-02-01 16:32:32
【问题描述】:
这是 JOIN:
SELECT
gc3025_raid_results.raid_id,
gc3025_game_units.planet_id,
gc3025_game_units.g_dist,
gc3025_game_units.unit_name,
gc3025_units_base.unit_type,
gc3025_game_units.code,
gc3025_game_units.cdamage,
gc3025_units_base.defense_raid_score,
gc3025_units_base.raid_damage
FROM gc3025_game_units
JOIN gc3025_units_base
ON gc3025_game_units.code = gc3025_units_base.unit_code
JOIN gc3025_raid_results
ON gc3025_raid_results.district_idg = gc3025_game_units.g_dist
然后我需要插入到另一个表中
INSERT INTO gc3025_raid_defenders(
raid_ids, planet_id, district_id,
unit_name, unit_type, unit_code,
raid_score, raid_damage)
SELECT ... (see above) ...
任何建议将不胜感激。
【问题讨论】:
-
它有效,但它也在表中创建了超过一百万个重复项。应该只有 4 个。
标签: php mysql sql-insert jointable