Jump to content

any way to handle pointer-like references?


voodoochicken

Recommended Posts

hi, i have a table with a field 'other_entry' (let's suppose), which is another entry in the same table, for example:integer key, integer key_of_related_entry, integer other_field, enum('value1', 'value2', etc) criteriakey is the unique integer key to the entry, and key_of_related_entry is the key to another entryi want to do something likeupdate 'table'set other_field = (key_of_related_entry -> other_field)+1where criteria=valuexhow do i handle the 'pointer-like' reference, where the value in 'other_field' depends on the value of this same field, but in some other entry of the same table? tnx

Link to comment
Share on other sites

I can't find notes in the MySQL manual on what types of expressions you can use for the value of a column, but this might work:UPDATE table AS a SET other_field = (SELECT other_field FROM table AS b WHERE b.key = a.other_key) + 1 WHERE ...

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...