[英]Query Update row with data from another row in the same table
I have table like this... with 3000+ records.. 我有这样的表...有3000多个记录..
╔═════╦════════╦═════════════╗
║ id ║ text ║ parent_id ║
╠═════╬════════╬═════════════╣
║ 1 ║ asas ║ 0 ║
║ 2 ║ fgh ║ 0 ║
║ 3 ║ jkl ║ 0 ║
║ 4 ║ kkk ║ 0 ║
║ 5 ║ test ║ 0 ║
║ 6 ║ asd ║ 0 ║
║ 7 ║ dsa ║ 0 ║
╚═════╩════════╩═════════════╝
how to change the parent_id value to same like id? 如何将parent_id值更改为与id相同? to like this...
喜欢这个...
╔═════╦════════╦═════════════╗
║ id ║ text ║ parent_id ║
╠═════╬════════╬═════════════╣
║ 1 ║ asas ║ 1 ║
║ 2 ║ fgh ║ 2 ║
║ 3 ║ jkl ║ 3 ║
║ 4 ║ kkk ║ 4 ║
║ 5 ║ test ║ 5 ║
║ 6 ║ asd ║ 6 ║
║ 7 ║ dsa ║ 7 ║
╚═════╩════════╩═════════════╝
and more..... until 3000+records.. 以及更多.....直到3000多个记录
就像这样简单:
update yourtable set parent_id = id
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.