Hi
I have a table 1 with postcodes and a flag field that indicates whether it
is welsh.
I have another table (table 2) which has a list of just the first 5
characters of welsh postcodes that I want to use as a lookup table and if
there is a match with the postcode field in table 1 I set the flag field in
table 1 to 1 - how can I formulate the query for this?
Thanks
vinu - 14 Jul 2008 10:24 GMT
jojo
here is update statement
update t1 set FlagColumn=1 from
table1 t1 inner join table2 t2 on t2.column=left(t1.postcode,5)
vinu
> Hi
>
[quoted text clipped - 8 lines]
>
> Thanks
jojo123 - 14 Jul 2008 17:09 GMT
Thanks for that
Is it possible to update two tables in one update query? something like
update t1, t3 set FlagColumn=1 from
(table1 t1 inner join table2 t2 on t2.column=left(t1.postcode,5)) AND
(table3 t3 innerjoin table2 t2 on t2.column=left(t3.postcode,5))
> jojo
>
[quoted text clipped - 17 lines]
> >
> > Thanks
Tom Cooper - 14 Jul 2008 18:25 GMT
No. An update statement can only update one table.
Tom
> Thanks for that
>
[quoted text clipped - 28 lines]
>> >
>> > Thanks
Uri Dimant - 14 Jul 2008 10:31 GMT
UPDATE [table 1] SET flag=1 FROM
[table 1] t1 JOIN [table 2] t2 ON
SUBSTRING(t1,colname,1,5)=t2.colname
WHERE ........
> Hi
>
[quoted text clipped - 8 lines]
>
> Thanks