Bob Quintal <rq******@sympatico.ca> wrote in
news:Xn**********************@207.35.177.135:
See my fix, I had an = instead of an IS, which will always be
false.
"re***********@yahoo.fr" <re***********@yahoo.fr> wrote in
news:11*********************@e56g2000cwe.googlegro ups.com:
Hello
I am trying to update table1 and set a new value with a
condition selecting only the results for the element with the
specified ID and the first one with the Date field null.
The query executes but it doesn t not update the
informations. I ve tried using TOP 1 and spent hours on this
query but i can t get it to work.
UPDATE table1 SET table1.Name = newName
WHERE table1.Date = (SELECT First(table1.Date) FROM table1
WHERE table1.Date = Null And table1.ID = specifiedID);;
thank you for your help
Updating the first row which is null
If table1.date is null, then WHERE table1.Date = (SELECT ....
will never be true, and will not return any recoords.
try
SELECT TOP 1 Date FROM Table1
WHERE table1.Date IS Null
AND table1.ID = specifiedID
;
as a query, and use that query in the update
UPDATE table1
SET table1.Name = newName
FROM query1
;
When the two queries work correctly, you can optionally merge
them to get something like
UPDATE table1
SET table1.Name = newName
FROM (SELECT TOP 1 Date FROM Table1
WHERE table1.Date IS Null
AND table1.ID = specifiedID
)
;
--
Bob Quintal
PA is y I've altered my email address.