user1464296
user1464296

Reputation:

mysql trigger variables

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?

Upvotes: 0

Views: 292

Answers (1)

Joachim Isaksson
Joachim Isaksson

Reputation: 180917

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.

Upvotes: 2

Related Questions