I have a table that looks like this:
ID name emp_id
1 Sally 456
2 unknown 457
3 Kate null
4 unknown 890
5 James null
I know it's crazy, but it's what I'm dealing with according to business case.
I need to sometimes update the name, sometimes the emp_id. PLUS, I need to return back the updated or inserted ID.
If it were MSSQL, I'd do this:
IF EXISTS (SELECT 1 FROM tblEmp WHERE name = 'Kate')
UPDATE tblEmp SET emp_id = 767 WHERE name = 'Kate'
INSERT INTO tblEmp Set emp_id = 767, name = 'Kate'
How can I do this elegantly using mySQL?