SQL help

Поиск
Список
Период
Сортировка
От Chad Thompson
Тема SQL help
Дата
Msg-id 00ad01c2a20c$397b62d0$32021aac@chad
обсуждение исходный текст
Ответы Re: SQL help  ("Josh Berkus" <josh@agliodbs.com>)
Список pgsql-novice
I have a problem that I know can be solved if I can only explain it properly.
 
I have 3 tables, clients, projects and list_of_lists. Each has an Id field
 
select
c.id as client_id, p.id as project_id, l.id as list_of_lists_id
from
clients c inner join list_of_lists l on c.id = l.client_id
inner join projects p on c.id = p.client_id
 
This gives me every client, their projects and every list.  I want most of this but not all.
 
select
c.id as client_id, p.id as project_id, l.id as list_of_lists_id
from
clients c inner join projects p on c.id = p.client_id
inner join list_of_lists l on p.id = l.project_id
 
This gives me only those lists that are associated with specific projects.
If you havent guessed already Im trying to recover from bad database design.
 
So what Im looking for is a list, like that of the first query, but if a project only has specific lists associated with it, I want only those from the second query. 
 
Does that make any sense?
Any help is appreciated
Chad
 
 
 
 

В списке pgsql-novice по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: NOTICE: can't shrink relation
Следующее
От: "Josh Berkus"
Дата:
Сообщение: Re: SQL help