Friday, 6 September 2013

A SQL query for nested update in mysql

A SQL query for nested update in mysql

I have a table which consist of 4 fields. They are Id, parent_id,
cat_name, flag. The data I had here is
(1, 1, test1, Y),
(2, 1, test2, Y),
(3, 2, test3, Y),
(4, 3, test4, Y),
(5, 4, test5, Y),
(6, 1, test6, Y),
(7, 1, test7, Y),
(8, 1, test8, Y).
In the required task of mine, I need to change all the flag value to N,
which have the ID 2 associated with it. Like if I have given the ID = 2 as
a parameter, all the field i,e.
(2, 1, test2, Y),
(3, 2, test3, Y),
(4, 3, test4, Y),
(5, 4, test5, Y)
will have the flag value as N.

No comments:

Post a Comment