Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

MYSQL

delimiter $$
create procedure select_or_insert()
begin
  IF EXISTS (select * from users where username = 'something') THEN
    update users set id= 'some' where username = 'something';
  ELSE 
    insert into users (username) values ('something');
  END IF;
end $$
delimiter ;
Source by dba.stackexchange.com #
 
PREVIOUS NEXT
Tagged: #MYSQL
ADD COMMENT
Topic
Name
9+7 =