dbTalk Databases Forums  

Two table joins

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss Two table joins in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Kumar S
 
Posts: n/a

Default Two table joins - 10-14-2004 , 10:18 AM






Hi all,

I have 3 tables like the following:

sample_table:
samp_id
samp_desc
samp_data


Experiment table:
exp_id
samp_id
exp_slot_id
exp_data1
exp_data2

exp_slot_table
exp_slot_id
exp_id
exp_slot_name


Now I want to update column samp_id in experiment
table.

I want to introduce samp_id = 3 and with a clause :
update samp_id in experiment table WHERE exp_slot_name
= 3264.dat; Here 3264.dat has exp_slot_id which is
present as a column in experiment table.

Can any one help me to get a correct update statement.
I am confused here.

My wrong SQL statement:

update experiment SET samp_id =3 WHERE (select
exp_slot_name = 4264.dat WHERE exp_slot_id =
exp_slot_name);

Thank you.
Kumar




__________________________________
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
http://promotions.yahoo.com/new_mail

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html


Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: Two table joins - 10-15-2004 , 09:29 AM






Kumar S <ps_postgres (AT) yahoo (DOT) com> writes:
Quote:
My wrong SQL statement:

update experiment SET samp_id =3 WHERE (select
exp_slot_name = 4264.dat WHERE exp_slot_id =
exp_slot_name);
I think you want something like

update experiment SET samp_id = 3
WHERE exp_slot_id = (SELECT exp_slot_id FROM exp_slot_table
WHERE exp_slot_name = '4264.dat');

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster



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 - 2012, Jelsoft Enterprises Ltd.