469,917 Members | 1,764 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,917 developers. It's quick & easy.

polating (insert into...) a table with determined record from another table.

Dear my friends...

I created a table (named : sven1). I want to populate
this table with the record from another table (named :
appoinment).
but I don't know how to formulate the sql query.

I tried this one:
insert into sven1 (custid, noapp) values ((select
custid from appointment where done='N' and
salesid='6'), (select noapp from appointment where
done='N' and salesid='6'));

But I got this error in my psql console:
kv=# insert into sven1 (custid, noapp) values ((select
custid from appointment where done='N' and
salesid='6'), (select noapp from appointment where
done='N' and salesid='6'));
ERROR: more than one row returned by a subquery used
as an expression
kv=#

Anybody would be so nice to help me solving this
problem?

Thank you very much in advance.

__________________________________
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #1
2 2353
In article <20************************@web41803.mail.yahoo.co m>,
Prabu Subroto <pr***********@yahoo.com> writes:
Dear my friends...
I created a table (named : sven1). I want to populate
this table with the record from another table (named :
appoinment).
but I don't know how to formulate the sql query. I tried this one:
insert into sven1 (custid, noapp) values ((select
custid from appointment where done='N' and
salesid='6'), (select noapp from appointment where
done='N' and salesid='6'));


It's far easier:

INSERT INTO sven1 (custid, noapp)
SELECT custid, noapp
FROM appointment
WHERE done = 'N'
AND salesid = '6'
---------------------------(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

Nov 23 '05 #2
It's solved....

Thank you very...very...much my friend Harald.
--- Harald Fuchs <hf*****@protecting.net> wrote:
In article
<20************************@web41803.mail.yahoo.co m>, Prabu Subroto <pr***********@yahoo.com> writes:
Dear my friends...
I created a table (named : sven1). I want to

populate
this table with the record from another table

(named :
appoinment).
but I don't know how to formulate the sql query.

I tried this one:
insert into sven1 (custid, noapp) values ((select
custid from appointment where done='N' and
salesid='6'), (select noapp from appointment where
done='N' and salesid='6'));


It's far easier:

INSERT INTO sven1 (custid, noapp)
SELECT custid, noapp
FROM appointment
WHERE done = 'N'
AND salesid = '6'
---------------------------(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


__________________________________
Do you Yahoo!?
Vote for the stars of Yahoo!'s next ad campaign!
http://advision.webevents.yahoo.com/...otelifeengine/

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

16 posts views Thread by Philip Boonzaaier | last post: by
6 posts views Thread by rn5a | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.