dbTalk Databases Forums  

Outer Join on 3 tables

comp.databases.postgresql.general comp.databases.postgresql.general


Discuss Outer Join on 3 tables in the comp.databases.postgresql.general forum.



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

Default Outer Join on 3 tables - 11-25-2005 , 04:25 PM






I am using Postgres 7.4.6 i have 3 tables i want to join 3 tables and
return a list of route_id to which a specified user_id does NOT belong.


Table "public.vts_users"
Column | Type | Modifiers
------------+------------------------+--------------------------------------
--------------------------
user_id | integer | not null default
nextval('public.vts_users_user_id_seq'::text)
username | character varying(255) | not null
password | character varying(50) |
role_id | integer |
first_name | character varying(50) |
last_name | character varying(50) |
timezone | character varying(3) | default 'MST'::character varying
Indexes:
"vts_users_pkey" primary key, btree (user_id)
"vts_users_username_key" unique, btree (username)
Foreign-key constraints:
"$1" FOREIGN KEY (role_id) REFERENCES vts_roles(role_id)

vtsdev=# \d vts_routes
Table "public.vts_routes"
Column | Type |
Modifiers
--------------------+------------------------+------------------------------
------------------------------------
route_id | integer | not null default
nextval('public.vts_routes_route_id_seq'::text)
route_name | character varying(50) |
route_description | character varying(255) |
always_web_visible | boolean | not null default false
school_id | integer |
Indexes:
"vts_routes_pkey" primary key, btree (route_id)
Check constraints:
"route_name_nn" CHECK (route_name IS NOT NULL)

vtsdev=# \d vts_parent_route_link
Table "public.vts_parent_route_link"
Column | Type | Modifiers
-----------+---------+------------------------------------------------------
------------------------
prlink_id | integer | not null default
nextval('public.vts_parent_route_link_prlink_id_se q'::text)
user_id | integer |
route_id | integer |
Indexes:
"vts_parent_route_link_pkey" primary key, btree (prlink_id)
"vts_parent_route_link_user_id_key" unique, btree (user_id, route_id)
Check constraints:
"user_id_nn" CHECK (user_id IS NOT NULL)
"route_id_nn" CHECK (route_id IS NOT NULL)
Foreign-key constraints:
"$1" FOREIGN KEY (user_id) REFERENCES vts_users(user_id)
"$2" FOREIGN KEY (route_id) REFERENCES vts_routes(route_id)



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.