Re: SELECT from multiple tables (not join though)
От | Madison Kelly |
---|---|
Тема | Re: SELECT from multiple tables (not join though) |
Дата | |
Msg-id | 41E2BFC9.6090605@alteeve.com обсуждение исходный текст |
Ответ на | Re: SELECT from multiple tables (not join though) (John Sidney-Woollett <johnsw@wardbrook.com>) |
Ответы |
Re: SELECT from multiple tables (not join though)
Re: SELECT from multiple tables (not join though) |
Список | pgsql-general |
John Sidney-Woollett wrote: > I hope I've read your question properly - I seem to be giving answers to > un-asked questions lately! ;) > > How about... > > SELECT file_name from file_info_1 WHERE file_name='/' > union > SELECT file_name from file_info_2 WHERE file_parent_name='/' > union > SELECT file_name from file_info_3 WHERE file_parent_name='/' > order by file_name; > > Does that do what you want? > > John Sidney-Woollett That worked perfectly, though now I realize I have another problem that is hopefully easy to get around. Here is my query (with the type fixed): SELECT file_name FROM file_info_1 WHERE file_parent_dir='/' UNION SELECT file_name FROM file_info_2 WHERE file_parent_dir='/' UNION SELECT file_name FROM file_info_3 WHERE file_parent_dir='/' ORDER BY file_name; The trick now is I need to know which table each result came from. I can add another column and record the table number and SELECT that at the same time but before I do I was wondering if I can do this more efficiently or elegantly. Thank you very much! Madison
В списке pgsql-general по дате отправления: