0

I have table like this... with 3000+ records..

╔═════╦════════╦═════════════╗
║ 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? 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..

1
  • UPDATE table SET parent_id = id? Commented Mar 18, 2016 at 10:40

1 Answer 1

2

It's as simple as:

update yourtable set parent_id = id

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.