I need a little help with my query..
I need to check my database first if the data im going to insert already exists in a table.
here's my code:
Code: Select all
INSERT INTO tnames(name) VALUES ('a name')
SELECT name FROM tnames WHERE NOT EXISTS
(SELECT NAME FROM tnames WHERE name = 'a name');
Can anyone help me with this?
I really need your help guys,
Ideas are greatly appreciated..