Possible Duplicate:
How to 'insert if not exists' in MySQL?
I want to do a select statement but if no rows match then i'd like to insert a row and get the row id. I'm not sure how to write the statement. I figured out this but i'm unsure if it works but if it does is there an easier way to write it?
insert into Blah(a,b,c) select aval, bval, cval
where null = (
select id from tbl where cond=1
);
select id from tbl where cond=1;