Board index » delphi » Help rewriting this query..

Help rewriting this query..

Hi..

I posted this on a Microsoft newsgroup but got no answers. I'm trying to
rewrite this
query:

UPDATE LOCALTABLEROOMSTATUS
SET
GUESTKEY = (select custkey from webtablereservations where reskey = '11937')
WHERE
ROOMNUMB = (select ROOMNUMB from webtablereservations where reskey ='11937')

To something like this:

UPDATE LOCALTABLEROOMSTATUS
SET GUESTKEY = b.custkey
WHERE ROOMNUMB = B.ROOMNUMB
FROM (SELECT * FROM WEBTABLERESERVATIONS WHERE RESKEY = '11937') AS B

because I have multiple fields I want to update in ROOMSTATUS from
WEBTABLERESERVATIONS

Thanks

Rich

 

Re:Help rewriting this query..


Does this do it?

update LocalTableRoomStatus set GuestKey = CustKey
from WebTableReservations b
where LocalTableRoomStatus.RoomNumb = b.RoomNumb and b.ResKey = 10

--
Steve
http://www.krell-software.com
Database Development Tools for MS SQL Server

Quote
"Richard Morey" <rwmo...@27east.com> wrote in message

news:3c092d70$1_1@dnews...
Quote
> Hi..

> I posted this on a Microsoft newsgroup but got no answers. I'm trying to
> rewrite this
> query:

> UPDATE LOCALTABLEROOMSTATUS
> SET
> GUESTKEY = (select custkey from webtablereservations where reskey =
'11937')
> WHERE
> ROOMNUMB = (select ROOMNUMB from webtablereservations where reskey
='11937')

> To something like this:

> UPDATE LOCALTABLEROOMSTATUS
> SET GUESTKEY = b.custkey
> WHERE ROOMNUMB = B.ROOMNUMB
> FROM (SELECT * FROM WEBTABLERESERVATIONS WHERE RESKEY = '11937') AS B

> because I have multiple fields I want to update in ROOMSTATUS from
> WEBTABLERESERVATIONS

> Thanks

> Rich

Other Threads