In MYSQL, how do you assign a field name fname from the table ftable to a variable within a trigger query?
I am aware of mysql global variables: @@
Local Variables? @
But is that even the right syntax?
You can just assign it from the field right in the select; it would get the last selected value if several rows are returned.
SELECT @tmp:=fvalue FROM ftable WHERE ...
A simple SQLfiddle here.
@tmp having the value of fname that I can use in the rest of the trigger script?@tmp will have the value of that field. That is, if ftable has only one row where the field value of fvalue is 1, @tmp will contain the value 1.