I currently have 4 tables,
Guardian
-Name -RankingGTimes开发者_运维问答
-Name -RankingTIdentity
-idName -NameRanking
-idName -RankingT -RankingGTimes and Guardian do have some different names. I have currently inserted the Names from Times and Guardian into Identity with an autoincrement idName. Now how do I insert the RankingT into Ranking from Times with the corresponding idName from Identity and do the same with RankingG from Guardian
Note: This will not work if there are duplicate Name's:
INSERT Ranking (idName, RankingT)
SELECT i.idName, t.RankingT, g.RankingG
FROM `Identity` i
LEFT JOIN Times t USING(Name)
LEFT JOIN Guardian g USING(Name)
精彩评论