create table foo
 (aa varchar(20),
  id integer,
  cc varchar(20));

delimiter |

create trigger foo_ins before insert on foo
for each row 
begin
    set new.aa = concat(new.cc,'-',new.id);
end; |
delimiter ;

insert into foo (cc,id) values ('www',1);
select * from foo;
 

-----Original Message-----
From: bruce [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 19, 2007 7:59 PM
To: 'mysql list'
Subject: trigger question..

hi.

using mysql 5.0.27 and playing with triggers.

a simple db:
 create table foo{
 aa varchar (10),
 bb int auto_increment,
 cc varchar (10),
} innondb

i'm trying to figure out how to create a trigger, such that if the user does
an insert into foo (cc) value ("www"); the table will concat the www with
the 'id' value to produce:

 foo
  aa            bb      cc
 www-1  1       www

i've been reviewing triggers, and various examples, and for the life of me,
i can't figure out how to modify a field of the row or the item i'm
triggering off of...

any thoughts/comments/pointers would be helpful!!

thanks


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Internal Virus Database is out-of-date.
Checked by AVG Free Edition. 
Version: 7.5.503 / Virus Database: 269.16.17 - Release Date: 12/6/2007 12:00
AM
 

Internal Virus Database is out-of-date.
Checked by AVG Free Edition. 
Version: 7.5.503 / Virus Database: 269.16.17 - Release Date: 12/6/2007 12:00
AM
 


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to