Update Statement

Update Statement

Post by Toby » Fri, 05 Jul 2002 07:25:09



I'm trying to update one table with certain while another table holds the
records that the first table needs to find a specific record

Table A

ID
SSN
CreditNumber

Table B
ID
SSN
STATUS

I want table A to update itself only on the SSN records that match the SSN
records in Table B and the status in Table B is CAN

All help is appreciated

Thanks

 
 
 

Update Statement

Post by Mikhail Berlyan » Fri, 05 Jul 2002 07:30:15


update a set ...
from TableA as a
join TableB as b
on a.ssn = b.ssn
and b.status = 'CAN'

Mikhail Berlyant
Data Integrator, Data Systems
Launch Your Yahoo!Music Experience  http://launch.yahoo.com
Brainbench MVP for Visual Basic   www.brainbench.com


Quote:> I'm trying to update one table with certain while another table holds the
> records that the first table needs to find a specific record

> Table A

> ID
> SSN
> CreditNumber

> Table B
> ID
> SSN
> STATUS

> I want table A to update itself only on the SSN records that match the SSN
> records in Table B and the status in Table B is CAN

> All help is appreciated

> Thanks


 
 
 

1. Help me convert a SELECT statement to an UPDATE statement

Hi,

I am trying to update a field in a table with the value in a field from
another table.. This is the SELECT statment I've run to see the two values
side by side:

SELECT     a.RESKEY, a.ROOMNUMB, a.CCFEE, b.DCARD
FROM         webTableReservations a INNER JOIN
                      seattdata b ON b.DBEGIN = a.ARRIVE AND b.DROOM =
a.ROOMNUMB
WHERE     (a.CCFEE IS NULL)

What I am try to do is this..

UPDATE webTableReservations as a
SET a.CCFEE = b.DCARD
WHERE b.DBEGIN = a.ARRIVE AND b.DROOM = a.ROOMNUMB

Execept that when I try to run this SQL I get an "Incorrect Syntax Near
Keyword AS"

I've tried re-working the SQL statment a few different ways, but can't get
it to execute..

Thanks,

Rich

2. HELP: master..sysprocesses

3. Update statement with correlated subquery inside case statement fails

4. auto-fill in FM4pro ?

5. Case Statement in Update Statement

6. MA-Boston - Informix, 4GL, SUN

7. Update statement creates Error, when statement is fine

8. Space/rows for all the tables

9. Problem updating same row twice in update statement

10. UPDATE statement may update more records than expected

11. Update locks in multi-table update statements

12. Updating records with UPDATE Statement error

13. Update Memo-Column with SQL UPDATE Statement