How to declare variable in trigger with MySQL?

How do I do this MYSQL trigger between 2 tables?

  • For example If I had 2 columns on TABLE1 called "id" and "count" that contains numbers, when those numbers reach 50 or over then I want the trigger to update a column called "reached" on TABLE2 with "yes" along with its id, in the id column How can it be done? Thanks

  • Answer:

    Try something along these lines:- CREATE TRIGGER ReachedTrig AFTER INSERT, UPDATE ON Table1 FOR EACH ROW BEGIN INSERT INTO Table2 SELECT 'Yes' AS Reached, id = Table1.id FROM Table1 WHERE `Count` >= 50 END; You might need to tweak the syntax a little, I'm more used to MSSQL I'm afraid, I'm a bit rusty on MySQL... :)

J0nny3 at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

Great question. I don't know the answer. You will probably have better luck asking it on a more knowledgeable programming site like stackoverflow.com . Most of the people here answer simple questions (you might still get a response, who knows)

Steve

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.