update query : please help!

  • Thread starter Thread starter bluefalcon904 via AccessMonster.com
  • Start date Start date
B

bluefalcon904 via AccessMonster.com

hi.. am such a newbie with SQL. im trying to update a table to overwrite a
record .

TABLE1
ORDERNUM NAME EVENT ORIGORDER
1 GEE ADD <NULL>
2 MAY ADD <NULL>
3 CHANGE 1
3 CHANGE 2

what i want to achieve is : if EVENT is CHANGE, then overwrite ORDERNUM with
ORIGORDER so the output would be:

ORDERNUM NAME EVENT ORIGORDER
3 GEE ADD <NULL>
3 MAY ADD <NULL>

other data will be the same except for ORDERNUM.

Can you please help me?
 
Hi, this newsgroup is about ADP projects and SQL-Server, so a newsgroup such
as m.p.access.queries might be better suited to your question.

As to it, the T-SQL language used with SQL-Server is slightly different from
the sql used in Access, so the following example might or might not work
with Access:

Update t1 set t1.ordernum = t2.ordernum
From table1 t1 join table1 t2 on t1.ordernum = t2.origorder
Where t2.event = 'CHANGE'
 
HI Sylvain...

Thank you so much! it worked! sorry if i entered my inquiry here.. but
thought that all SQL works the same... and it did. :)

Carl


Sylvain said:
Hi, this newsgroup is about ADP projects and SQL-Server, so a newsgroup such
as m.p.access.queries might be better suited to your question.

As to it, the T-SQL language used with SQL-Server is slightly different from
the sql used in Access, so the following example might or might not work
with Access:

Update t1 set t1.ordernum = t2.ordernum
From table1 t1 join table1 t2 on t1.ordernum = t2.origorder
Where t2.event = 'CHANGE'
hi.. am such a newbie with SQL. im trying to update a table to overwrite a
record .
[quoted text clipped - 20 lines]
 
Excerpt for basic things like simple Select statements, the T-SQL used on
SQL-Server is very different fromt the sql language used in Access.

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: sylvain aei ca (fill the blanks, no spam please)


bluefalcon904 via AccessMonster.com said:
HI Sylvain...

Thank you so much! it worked! sorry if i entered my inquiry here.. but
thought that all SQL works the same... and it did. :)

Carl


Sylvain said:
Hi, this newsgroup is about ADP projects and SQL-Server, so a newsgroup
such
as m.p.access.queries might be better suited to your question.

As to it, the T-SQL language used with SQL-Server is slightly different
from
the sql used in Access, so the following example might or might not work
with Access:

Update t1 set t1.ordernum = t2.ordernum
From table1 t1 join table1 t2 on t1.ordernum = t2.origorder
Where t2.event = 'CHANGE'
hi.. am such a newbie with SQL. im trying to update a table to overwrite
a
record .
[quoted text clipped - 20 lines]
 
Back
Top