i have a table like this:
ID ID_USER SOURCE CONTENT
or just:
CREATE TABLE `p_l_0215` (
`id` bigint(20) NOT NULL auto_increment,
`id_user` bigint(20) NOT NULL,
`source` varchar(50) NOT NULL,
`content` text NOT NULL,
KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
I want to update when ID_USER=Value1 and SOURCE=‘default’ if this condition do not exist i want to insert. I know the method when i have a duplicate key, but in this table ID_USER neither SOURCE could be UNIQUE. So how can i solve this? Thanks for any help!
1) create the procedure
2) then just call it like this
CALL smartInsert(13, 'some_source', 'some content');