I just finished picking up my jaw off the floor after learning that you can't use an IF statement in a query in MySql. How can anyone get anything done without an IF statement?!
What I'm trying to do is write a DML script that adds a constraint to a table, if it doesn't exist. Something like this:
if (select count(*) from information_schema.table_constraints
where constraint_name='fk_user_user_status') = 0
then
alter table `user`
add constraint fk_user_user_status foreign key (status_id)
references user_status(id);
end if;
How would one do this in MySql?
Thanks in advance!