K
KH
Hi,
I can't seem to get the syntax right for an insert query. In Sql Server I
would do this:
INSERT INTO [bla] (a, b, c)
SELECT 0, 'foo', NULL
WHERE NOT EXISTS(SELECT * FROM [bla] WHERE a = 0)
So, don't insert the new row if there's already a row where (a = 0).
But Access complains that there's no table in the SELECT query.
I tried a derived table to no avail, and this:
INSERT INTO [bla] (a, b, c)
SELECT TOP 1 0, 'foo', NULL
FROM [bla]
WHERE NOT EXISTS(SELECT * FROM [bla] WHERE a = 0)
but that doesn't work if [bla] has no rows.
Anybody know how to do that in Access? Thanks in advance!
- KH
I can't seem to get the syntax right for an insert query. In Sql Server I
would do this:
INSERT INTO [bla] (a, b, c)
SELECT 0, 'foo', NULL
WHERE NOT EXISTS(SELECT * FROM [bla] WHERE a = 0)
So, don't insert the new row if there's already a row where (a = 0).
But Access complains that there's no table in the SELECT query.
I tried a derived table to no avail, and this:
INSERT INTO [bla] (a, b, c)
SELECT TOP 1 0, 'foo', NULL
FROM [bla]
WHERE NOT EXISTS(SELECT * FROM [bla] WHERE a = 0)
but that doesn't work if [bla] has no rows.
Anybody know how to do that in Access? Thanks in advance!
- KH