Re: update query

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: John Vinson (jvinson_at_STOP_SPAM.WysardOfInfo.com)
Date: 08/26/04


Date: Wed, 25 Aug 2004 23:50:48 -0600

On Wed, 25 Aug 2004 17:41:02 -0700, yaahee
<yaahee@discussions.microsoft.com> wrote:

>what is the difference between "not like" and " is not"

The LIKE operator recognizes wildcards (for example # matches any
numeric digit, * matches any string). So a criterion

LIKE "a*c"

will match any string which starts with a and ends with c.

NOT LIKE "a*c"

will match any string UNLESS it starts with a and ends with c.

IS NOT is valid only in the context IS NOT NULL and will return the
record if there is any value whatsoever in the field.

>Could anyone tell me what is wrong with this query.
>
>UPDATE table1 AS table1 SET table1.field1 = table1. field2 WHERE
>table1.field2 is not null
>
>how come it ask me input table1. field2 value to run the query?

Probably because you have an extra blank between table1. and field2.
Is there in fact a field named Field2 in your query?

Also, the AS table1 clause is not necessary - you're just defining
"table1" as an alias for "table1", which would be a bit like John
Dillinger calling himself John Dillinger to conceal his identity!

Try

UPDATE Table1
SET Field1 = Field2
WHERE Field2 IS NOT NULL;

Assuming that you have both fields in the table, this should replace
the current contents of Field1 with the value in Field2; if Field2 has
nothing in it, Field1 will be left untouched.

                  John W. Vinson[MVP]
             (no longer chatting for now)



Relevant Pages