By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,799 Members | 1,316 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,799 IT Pros & Developers. It's quick & easy.

Select statment question

P: n/a
Dear All,
could you please help me with writing select statment for the following:
I have two tables
dictionary_text
label| Text
-----+------------------------
23 | General
24 | Internet
25 | General option group
26 | Internet option group

And
dictionary_optiongroup
id | name | description
----+------+-------------
0 | 23 | 25
1 | 24 | 26

How should i write SELECT statement to get the following:
name | description
---------+----------------------
General | General option group
Internet | Internet option group

I understand that maybe this question is not for this list, but my
brains stuck with this select. Could you please help.

Best regards,
Anton
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 22 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
select dt1.text as name, dt2.text as description
from dictionary_text dt1, dictionary_optiongroup do, dictionary_text dt2
where dt1.label = do.name and do.description = dt2.label;

not tested :)

Anton Nikiforov wrote:
Dear All,
could you please help me with writing select statment for the following:
I have two tables
dictionary_text
label| Text
-----+------------------------
23 | General
24 | Internet
25 | General option group
26 | Internet option group

And
dictionary_optiongroup
id | name | description
----+------+-------------
0 | 23 | 25
1 | 24 | 26

How should i write SELECT statement to get the following:
name | description
---------+----------------------
General | General option group
Internet | Internet option group

I understand that maybe this question is not for this list, but my
brains stuck with this select. Could you please help.

Best regards,
Anton
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

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

Nov 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.