MySQL FULL JOIN not working but RIGHT and LEFT join works

后端 未结 4 1442
遥遥无期
遥遥无期 2020-12-19 03:20

This is driving me nuts. I have two tables that I am attempting to preform a join on, usersXstats and usersXstats_alltime.

Both tables have the same columns: id, us

相关标签:
4条回答
  • 2020-12-19 03:47
    SELECT Person1.Firstname, Person2.State
    FROM Person1
    left JOIN Person2
    ON Person1.PersonID=Person2.PersonID
    UNION
    SELECT Person1.Firstname, Person2.State
    FROM Person1
    right JOIN Person2
    ON Person1.PersonID=Person2.PersonID;
    

    is working superbly.

    0 讨论(0)
  • 2020-12-19 04:04

    Take a look at this How to simulate FULL OUTER JOIN in MySQL. It may helps.

    0 讨论(0)
  • 2020-12-19 04:05

    MySQL doesn't support FULL JOIN

    http://en.wikipedia.org/wiki/Join_%28SQL%29#Full_outer_join

    0 讨论(0)
  • 2020-12-19 04:05

    FULL OUTER JOIN won't support in mysql.

    You can emulate FULL OUTER JOIN using UNION (from MySQL 4.0.0 on):

    with two tables usersXstats,usersXstats_alltime

    SELECT * FROM usersXstats
    LEFT JOIN usersXstats_alltime ON usersXstats.userId= usersXstats_alltime.userId
    UNION
    SELECT * FROM usersXstats
    RIGHT JOIN usersXstats_alltime ON usersXstats.statId= usersXstats_alltime.statId
    
    0 讨论(0)
提交回复
热议问题