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
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:
- How do I compare two tables with the same column definitions in different schemas?Best solution by Database Administrators
- How do I switch Myspace back from the 2.0 version?Best solution by Yahoo! Answers
- How can I power 4 speakers with a 2-channel amp?Best solution by Yahoo! Answers
- How can I downgrade my iOS from 4.2 to 4.01?Best solution by ChaCha
- How do i put a background on GIMP 2.6?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.