Sometimes, subqueries perform better than table joins, though. See the
article: http://www.tsqlsolutions.com/Articles/Index.cfm?ArticleID=22431
Look after the molehills and the mountains will take care of themselves.
-- Today's Fortune
"Raster, Tim" <[EMAIL PROTECTED]>
02/06/2003 04:02 PM
Please respond to sql
To: SQL <[EMAIL PROTECTED]>
cc:
Subject: RE: Update query question
I just don't like subqueries. They are unclear to read, and are usually
the source of more problems than they're worth. Just MHO.
-----Original Message-----
From: Phillip B [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 06, 2003 14:23
To: SQL
Subject: Re: Update query question
So my subquery is crap uh? ;)
Just kidding.
I don't know why I didn't think of the join method. I think I'll try it
since its easier to read.
Phillip B
----- Original Message -----
From: "Raster, Tim" <[EMAIL PROTECTED]>
To: "SQL" <[EMAIL PROTECTED]>
Sent: Thursday, February 06, 2003 2:07 PM
Subject: RE: Update query question
> I prefer the join method, rather than that subquery crap.
>
> Update a
> Set MyField = b.MyField
> >From tblA a inner join tblB b on a.ID = b.ID
>
>
> -----Original Message-----
> From: Phillip B [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, February 06, 2003 14:00
> To: SQL
> Subject: Update query question
>
> I need to set the value of one field in table tblA to the value in
table
> tblB with id being the same in both tables. Would this work?
>
>
>
> UPDATE
> tblA
> SET
> brand = (SELECT
> brand
> FROM
> tblB
> WHERE
> tblB.id= tblA.id)
>
> I'm using SQL2000.
>
> Phillip B
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=6
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=6
Get the mailserver that powers this list at http://www.coolfusion.com