MYSQL 全关联的问题,不能用FULL JOIN,可有良策

MYSQL 全关联的问题,不能用FULL JOIN,可有良策,第1张

SELECT

A.Name,

A.COLUMN1,

B.COLUMN2,

C.COLUMN3,

D.COLUMN4

FROM

A LEFT JOIN B

ON ( A.NAME = B.NAME )

LEFT JOIN C

ON ( A.NAME = C.NAME )

LEFT JOIN D

ON ( A.NAME = D.NAME )

UNION

SELECT

B.Name,

A.COLUMN1,

B.COLUMN2,

C.COLUMN3,

D.COLUMN4

FROM

B LEFT JOIN A

ON ( A.NAME = B.NAME )

LEFT JOIN C

ON ( B.NAME = C.NAME )

LEFT JOIN D

ON ( B.NAME = D.NAME )

UNION

SELECT

C.Name,

A.COLUMN1,

B.COLUMN2,

C.COLUMN3,

D.COLUMN4

FROM

C LEFT JOIN A

ON ( C.NAME = A.NAME )

LEFT JOIN B

ON ( B.NAME = C.NAME )

LEFT JOIN D

ON ( C.NAME = D.NAME )

UNION

SELECT

D.Name,

A.COLUMN1,

B.COLUMN2,

C.COLUMN3,

D.COLUMN4

FROM

D LEFT JOIN A

ON ( D.NAME = A.NAME )

LEFT JOIN B

ON ( B.NAME = D.NAME )

LEFT JOIN C

ON ( C.NAME = D.NAME )

PDATE mysql.user SET HOST = "localhost" WHERE USER = "root"

FLUSH PRIVILEGES

user 表中的第一个字段为%表示开启远程连接,把%删掉就是关闭远程连接了.


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/8460498.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-16
下一篇 2023-04-16

发表评论

登录后才能评论

评论列表(0条)

保存