amukta
asked on
Updating a row in a table with a composite primary key composed of 3 primary keys and one foreign key
I have a table with a composite primary key composed of the fields a,b and c and a foreign key 'd' and several other columns.
I hava a grid view for which I have dropdowns fora,b,c and d columns.
Now, my question is, when I update a row, can I update a, b, c or d individually while updating a row?
Please let me KNOW asap.
It's extremely urgent.
Thanks in advance.
I hava a grid view for which I have dropdowns fora,b,c and d columns.
Now, my question is, when I update a row, can I update a, b, c or d individually while updating a row?
Please let me KNOW asap.
It's extremely urgent.
Thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
IMITCHIE,
THANK YOU!
I HAVE ONE MORE QUESTION.
IS IT FINE TO UPDATE THIS WAY?
UPDATE TAB SET C=8 WHERE A=1,B=2,C=3 AND D=4?
similarly update tab set b=3 where A=1,B=2,C=3 AND D=4?
update tab set c=4 where A=1,B=2,C=3 AND D=4?
AND SINCE D IS THE FOREIGN KEY, CAN I UPDATE IT SAYING
UPDATE TAB SET D=9 WHERE A=@A, B=@B, C=@C AND D=@D?
PLEASE LET ME know ASAP.
THANKS IN ADVANCE
THANK YOU!
I HAVE ONE MORE QUESTION.
IS IT FINE TO UPDATE THIS WAY?
UPDATE TAB SET C=8 WHERE A=1,B=2,C=3 AND D=4?
similarly update tab set b=3 where A=1,B=2,C=3 AND D=4?
update tab set c=4 where A=1,B=2,C=3 AND D=4?
AND SINCE D IS THE FOREIGN KEY, CAN I UPDATE IT SAYING
UPDATE TAB SET D=9 WHERE A=@A, B=@B, C=@C AND D=@D?
PLEASE LET ME know ASAP.
THANKS IN ADVANCE
ASKER
ONE MORE QUESTION AND CN I ALSO UPDATE LIKE THIS?
UPDATE A=@A, B=@B,C=@C,D=@D WHERE A=@A,B=@B,C=@C,D=@D?
NOPE RIGHT? OR CAN I DO SO?
UPDATE A=@A, B=@B,C=@C,D=@D WHERE A=@A,B=@B,C=@C,D=@D?
NOPE RIGHT? OR CAN I DO SO?
ASKER
ONE MORE QUESTION AND CN I ALSO UPDATE LIKE THIS?
UPDATE A=@A, B=@B,C=@C,D=@D WHERE A=@A,B=@B,C=@C,D=@D?
NO RIGHT? OR CAN I DO SO?
UPDATE A=@A, B=@B,C=@C,D=@D WHERE A=@A,B=@B,C=@C,D=@D?
NO RIGHT? OR CAN I DO SO?
ASKER
ONE MORE QUESTION AND CN I ALSO UPDATE LIKE THIS?
UPDATE A=@A, B=@B,C=@C,D=@D WHERE A=@A,B=@B,C=@C,D=@D?
NO RIGHT? OR CAN I DO SO?
UPDATE A=@A, B=@B,C=@C,D=@D WHERE A=@A,B=@B,C=@C,D=@D?
NO RIGHT? OR CAN I DO SO?
yes, that is possible.
however, you should rethink your table design, and add a dedicated column as primary key (and eventually make your current pk a unique key).
this will make things, related to this table, a lot easier.
having composite primary keys is rarely a good design, with "1 exception":
a relation table with just the 2 foreign key field could very well be implemented with the primary key on just that 2 fields...