Cant get my Trigger to work
This trigger is designed to update 'field_csvfilepath_value' to match 'filepath' in the files table (some table details below). But I cant get it to work, please help.
delimiter $$
CREATE TRIGGER csv_filpath
AFTER INSERT ON content_type_importcsv for each row
begin
declare p varchar(80)
set p := (SELECT filepath FROM content_type_importcsv join files where NEW.content_type_importcsv.field_csv1_fid = files.fid)
set NEW.field_csvfilepath_value = p
end$$
delimiter ;
This trigger is generating the following error:
Error Code: 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 'set p := (SELECT filepath FROM content_type_importcsv join files where NEW.conte' at line 5
I'm using mysql workbench 5.2 Cheers
delimiter $$
delimiter $$
CREATE TABLE `content_type_importcsv` (
`vid` int(10) unsigned NOT NULL DEFAULT '0',
`nid` int(10) unsigned NOT NULL DEFAULT '0',
`field_csv1_fid` int(11) DEFAULT NULL,
`field_csv1_list` tinyint(4) DEFAULT NULL,
`field_csv1_data` text,
`field_csvfilepath_value` longtext,
PRIMARY KEY (`vid`),
KEY `nid` (`nid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8$$
CREATE TABLE `files` (
`fid` int(10) unsigned NOT NULL AUTO_INCREMENT,
`uid` int(10) unsigned NOT NULL DEFAULT '0',
`filename` varchar(255) NOT NULL DEFAULT '',
`filepath` varchar(255) NOT NULL DEFAULT '',
`filemime` varchar(255) NOT NULL DEFAULT '',
`filesize` int(10) unsigned NOT NULL DEFAULT '0',
`status` int(11) NOT NULL DEFAULT '0',
`timestamp` int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`fid`),
KEY `uid` (`uid`),
KEY `status` (`status`),
KEY `timestamp` (`timestamp`)
) ENGINE=MyISAM AUTO_INCREMENT=55 DEFAULT CHARSET=utf8$$