I have table table with three columns as follows
CREATE TABLE `auto_bulk` (
`bulk_id` int(5) NOT NULL auto_increment,
`heading` varchar(25) NOT NULL,
`content` text NOT NULL,
PRIMARY KEY (`bulk_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
I need to add some bulk records directly to mysql database.
INSERT INTO auto_bulk(heading,content)VALUES('xxx','xxx');
But my problem is I am giving only the content,heading should be the first 5 letters of content.Like,
INSERT INTO auto_bulk(heading,content)VALUES('Hello','Helloworld123');
I know how to do with php with substr but i would like to know is there any way to do it directly in mysql
I have tried this but no luck
INSERT INTO auto_bulk(heading,content)VALUES(SUBSTRING(content,1,5),'Helloworld123');
Thanks
Try: