cymru72
|
  |
| Joined: 26 Jan 2008 |
| Total Posts: 4362 |
|
|
| 25 Apr 2012 02:28 PM |
CREATE TRIGGER handleThreads AFTER UPDATE, INSERT ON Threads SELECT * FROM Threads ORDER BY update_time DESC DECLARE @ThreadCount int SET @ThreadCount = (SELECT COUNT(*) FROM Threads); IF @ThreadCount > 5 FOR EACH ROW BEGIN DELETE FROM Threads WHERE order_ID > 5 END END;
Not sure what's wrong :(? Trying to create a trigger on the 'Threads' table. Want it to update the order of the rows, count them and check if they exceed 5 and if so delete those that exceed that order number. Help pls :( |
|
|
| Report Abuse |
|
|
|
| 25 Apr 2012 04:05 PM |
| Is it giving you an error? |
|
|
| Report Abuse |
|
|
|
| 25 Apr 2012 04:05 PM |
| Also, have you gone to stackoverflow yet? |
|
|
| Report Abuse |
|
|
cymru72
|
  |
| Joined: 26 Jan 2008 |
| Total Posts: 4362 |
|
|
| 25 Apr 2012 04:09 PM |
Oh, whoops. I meant to post that.. Yeah, here it is:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' INSERT ON Threads SELECT * FROM Threads ORDER BY update_time DESC ' at line 1 |
|
|
| Report Abuse |
|
|
cymru72
|
  |
| Joined: 26 Jan 2008 |
| Total Posts: 4362 |
|
|
| 25 Apr 2012 04:11 PM |
| Ignore that, fixed it. Dw, thanks though |
|
|
| Report Abuse |
|
|