dbTalk Databases Forums  

table update using result from join

comp.databases.postgresql.sql comp.databases.postgresql.sql


Discuss table update using result from join in the comp.databases.postgresql.sql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Gary Stainburn
 
Posts: n/a

Default table update using result from join - 10-11-2004 , 04:49 AM






Hi folks.

I'm annoyed that I can't sus out something this simple.

The join below gives the output I want, but I can't work out how to
convert it to be an update on the requests field.

I want to append the customer name to the fuel (delivery details) field
and then update the customer field to be 'retail'. but I can't work out
the description update bit.

goole=# select r.r_fuel||' - Customer: '||c.c_des from requests r,
customers c
goole-# where r.r_c_id = c.c_id and c.c_id in (
goole(# 9, 10, 13, 27, 35, 36, 39, 42, 44, 51, 53, 54, 55, 56, 57, 58,
60, 65, 67, 69,
goole(# 74, 75, 77, 81, 82, 84, 88, 89, 90, 91, 92, 96, 98, 99, 100,
101, 102, 103,
goole(# 105, 108, 113, 114, 117, 118, 124, 125, 126, 131, 132, 135, 136,
137, 144,
goole(# 145, 148, 149, 150, 151, 154, 11, 37, 40, 41, 43, 48, 52, 59,
62,
goole(# 63, 68, 70, 71, 83, 86, 93, 104, 119, 120, 121, 123, 128, 129,
130,
goole(# 134, 138, 142, 146, 147, 152, 153, 19, 38, 85, 87, 94, 106, 112,
116,
goole(# 141, 143, 18, 110, 111, 115, 140, 24, 50, 133, 47, 64, 76, 95,
107,
goole(# 109, 127, 33, 46, 97);
?column?
-------------------------------------------------------------------------------------
RINGWAYS - Customer: SUBSCAN
RINGWAYS - Customer: MARTIN
? - Customer: N G BAILEY
? - Customer: CHECRON SITE SERVICES LTD
10 litres - Customer: CONSULTANT SERVICES
? - Customer: ALD AUTOMOTIVE
eskrigg yo19 6ez 9am - Customer: TRANSPORT MANAGEMENT
TRAILER / PE18 9UH / HALF ON DELIVERY - Customer: ALD AUTOMOTIVE
DRIVEN / WF16 0NF - Customer: CONSULTANT SERVICES
TRAILER / HALF TANK ON DELIVERY - Customer: LEX / SWINTON
DN14 0HR - Customer: CHECRON SITE SERVICES LTD
. - Customer: other fleet
[snip]
(256 rows)

goole=#

What I want is something like

update requests set r_fuel=<what>, r_c_id = 7 where r_c_id in (.......
--
Gary Stainburn

This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000


---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.