我想知道如何编写查询以从单个列中获取记录并将其推送到新列。我想要移动的记录在记录中的某处包含一个逗号。举个例子:
之前:
Column1
1. Smith, John
2. Sue, Maggie
3. Big Name Corp
之后:
Column1
1.
2.
3. Big Name Corp
Column2
1. Smith, John
2. Sue, Maggie
3.
非常感谢任何帮助!
答案 0 :(得分:2)
UPDATE `tbl` SET `col2` = `col1` WHERE `col1` LIKE "%,%"
UPDATE `tbl` SET `col1` = "" WHERE `col1` LIKE "%,%"
我认为它也适用于单个查询
UPDATE `tbl` SET `col2` = `col1`, `col1` = "" WHERE `col1` LIKE "%,%"