0
我有我的表這種線:SQL連接字符串沒有重複的行
id email1 email2 email3 all
1 [email protected] [email protected] [email protected] NULL
2 [email protected] NULL [email protected] NULL
3 [email protected] NULL [email protected] NULL
4 [email protected] [email protected] NULL NULL
5 [email protected] NULL [email protected] NULL
6 [email protected] [email protected] [email protected] NULL
有了這樣的要求:
UPDATE mytable SET all=concat_ws(';', email1, email2, email3);
我:
id email1 email2 email3 all
1 [email protected] [email protected] [email protected] [email protected];[email protected];[email protected]
2 [email protected] NULL [email protected] [email protected];[email protected]
3 [email protected] NULL [email protected] [email protected];[email protected]
4 [email protected] [email protected] NULL [email protected];[email protected]
5 [email protected] NULL [email protected] [email protected];[email protected]
6 [email protected] [email protected] [email protected] [email protected];[email protected];[email protected]
但我也需要刪除重複的電子郵件進行編輯:
id email1 email2 email3 all
1 [email protected] [email protected] [email protected] [email protected];[email protected]
2 [email protected] NULL [email protected] [email protected]
3 [email protected] NULL [email protected] [email protected];[email protected]
4 [email protected] [email protected] NULL [email protected];[email protected]
5 [email protected] NULL [email protected] [email protected]
6 [email protected] [email protected] [email protected] [email protected];[email protected];[email protected]
感謝您的幫助!
是啊,我不知道這是否是最好的解決辦法,但它的工作原理,謝謝 – Macbernie