This is the query I am trying:
INSERT INTO Product (ProductName, Description, Brand, Size, Variety, Manufacturer, Family, Category, SubCategory )
VALUES ('m', 'm', 'm', 'm', 'm', 'm', 'm', 'm', 'm')
WHERE NOT EXISTS (SELECT * FROM Product WHERE Product.ProductName = 'm')`
and this the exception I am getting:
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Query input must contain at least one table or query.
Add a constraint for the field ProductName in the table. This way the DBMS will not allow you to insert an entry with an existing ProductName.
Also it’s recommended to have a special Primary Key field (ProductId for example) populated using a sequence. It’s better when you need a reference to the product from either other table or some place beyond the DB.
P.S.: using a query that check if a row with specified ProductName doesn’t exist and then inserting a new row doesn’t actually saves you from duplicate products in the table. Two such queries being executed simultaneously in separate transactions both will be able to successfully insert a row into the table. As a result you’ll have a duplicate.