[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: SQL insert dupe prevention problem



Dirk wrote:
I have a SQL problem....

INSERT INTO table (a, b, c, d, e, f)
VALUES (
"72fa545b9cc60c3b0af851c155128a9d", "a", "b", "c", 1158935640, "f"
)
IF NOT
EXISTS (
SELECT *
FROM table
WHERE (
table.a = "72fa545b9cc60c3b0af851c155128a9d"
)
) ;



what I'm doing wrong? I want to check table.a to prevent inserting
dupes...  it says...

#1064 - You have an error in your SQL syntax.  Check the manual that
corresponds to your MySQL server version for the right syntax to use
near 'IF NOT EXISTS (SELECT * FROM rsstool_table WHERE (rsstool_table


THANKS!!!

Dirk



You really want to use a primary key or unique constraint on table.a in order to prevent duplicates from being entered. The documentation for your database should tell you how to set one up.

--Ben



Reply to: