PostgreSQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesPostgreSQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 26th, 2013, 03:01 AM
derstauner derstauner is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2010
Posts: 76 derstauner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 24 m 53 sec
Reputation Power: 4
Simple query help

Hi,

I have this table:

Code:
CREATE TABLE nyelvek
(
  nyelvkod character(2) NOT NULL,
  nyelv character varying(15) NOT NULL,
  alapert boolean,
  CONSTRAINT nyelvkod PRIMARY KEY (nyelvkod)
)
WITH (
  OIDS=FALSE
);
ALTER TABLE nyelvek OWNER TO postgres;


and this table:

Code:
CREATE TABLE idegenmegnev
(
  tipus character varying(3) NOT NULL,
  azonosito character varying(10) NOT NULL,
  nyelvkod character(2) NOT NULL,
  idegenmegnev character varying(60),
  jellszoveg character varying(40),
  CONSTRAINT imegnev PRIMARY KEY (tipus, azonosito, nyelvkod),
  CONSTRAINT nykod FOREIGN KEY (nyelvkod)
      REFERENCES nyelvek (nyelvkod) MATCH FULL
      ON UPDATE CASCADE ON DELETE CASCADE
)
WITH (
  OIDS=FALSE
);
ALTER TABLE idegenmegnev OWNER TO postgres;


I would like to select all the records form table1 and all the records from table2, where table2.tipus='SZ' and table2.azonosito='111000' with a join. The common field is 'nyelvkod'.

F.e. I get 3 records from table1 (all the rows are unique rows) and one row from table2, where one value from field 'nyelvkod' from table1 = field 'nyelvkod' from table2.

So at the end, I have 3 records, one column (nyelvkod) from table1 and 2 columns (idegenmegnev, jellszoveg) from table2.

Can you help me out?

EDIT: no need to answer

Code:
select nyelvek.nyelvkod, table1.idegen_megnev, table1.jellszoveg from nyelvek
left join
(select nyelvkod, idegen_megnev, jellszoveg from idegen_megnev where
tipus='SZ' and azonosito='111000') as table1
on nyelvek.nyelvkod=table1.nyelvkod

Last edited by derstauner : January 26th, 2013 at 07:26 AM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesPostgreSQL Help > Simple query help

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


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

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap