Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / DB Engine / SQL Server / July 2008

Tip: Looking for answers? Try searching our database.

Help with query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jojo123 - 14 Jul 2008 10:15 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.