RE: Dynamic link
[snip] Say I have two regular tables (table1, table2) and what a column (status) in the second table to update when it changes in table1. For example, if I set the status for a user in table1 to 0, the status for all that user's records in table2 dynamically changes to 0. Can this be done? What method is used? [/snip] http://www.mysql.com/trigger -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Dynamic link
On Wednesday 05 July 2006 11:40 am, Jay Blanchard wrote: [snip] Say I have two regular tables (table1, table2) and what a column (status) in the second table to update when it changes in table1. For example, if I set the status for a user in table1 to 0, the status for all that user's records in table2 dynamically changes to 0. Can this be done? What method is used? [/snip] http://www.mysql.com/trigger Why not a foreign key constraint in this case? Granted it would be something like ON DELETE SET NULL, and you'd have to verify that the columns were not NOT NULL, but the application logic should remain the same with regards to that. -- Chris White PHP Programmer Interfuel 805.642.2200 x110 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: Dynamic link
Is this the only option? I get Access denied. CREATE TRIGGER ins_sum BEFORE INSERT ON account FOR EACH ROW SET @sum = @sum + NEW.amount; MySQL said: Documentation #1227 - Access denied; you need the SUPER privilege for this operation This is sample code from mysql site, http://dev.mysql.com/doc/refman/5.1/en/using-triggers.html Thank you -- View this message in context: http://www.nabble.com/Dynamic-link-tf1896489.html#a5188173 Sent from the MySQL - General forum at Nabble.com. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Dynamic link
How would a foreign key constraint work in this case? Thank you -- View this message in context: http://www.nabble.com/Dynamic-link-tf1896489.html#a5188192 Sent from the MySQL - General forum at Nabble.com. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Dynamic link
On Wednesday 05 July 2006 12:26 pm, z247 wrote: How would a foreign key constraint work in this case? An example of a foreign key constraint would be something like: CREATE TABLE users ( id BIGINT UNSIGNED NOT NULL UNIQUE, username VARCHAR NOT NULL, password VARCHAR NOT NULL, status INT UNSIGNED, PRIMARY KEY (id), CONSTRAINT foreign_user_status FOREIGN KEY foreign_user_status (status) REFERENCES user_status (id) ON DELETE SET NULL ); another option is to have it as an ALTER TABLE statement: ALTER TABLE users ADD FOREIGN KEY(foreign_user_status) REFERENCES user_status ( id ); -- Chris White PHP Programmer/DBoo Interfuel -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Dynamic link
z247 wrote: Is this the only option? I get Access denied. CREATE TRIGGER ins_sum BEFORE INSERT ON account FOR EACH ROW SET @sum = @sum + NEW.amount; MySQL said: Documentation #1227 - Access denied; you need the SUPER privilege for this operation Read the error message. You don't have super privilege for your mysql user. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]