| От | Antonio Goméz Soto |
|---|---|
| Тема | Using table name in column for joining |
| Дата | |
| Msg-id | 4B435B11.2030909@gmail.com обсуждение исходный текст |
| Ответы |
Re: Using table name in column for joining
|
| Список | pgsql-general |
Hello,
I have a column in a table that contains the name of another table,
and the id in that table.
I would like to use this in a join statement. Is that possible?
example:
create table animal (
id serial,
table_name varchar(8) default 'monkey' CHECK (table_name IN ('monkey', 'elephant')),
table_id integer
);
create table monkey (
id serial,
name varchar(20)
);
create table elephant (
id serial,
name varchar(20)
);
and I want to do:
select animal.name from animal left join animal.table_name on animaltablename.id = animal.table_id;
or something like that.
I know it's probably considered bad SQL, but what else can I do?
Thanks,
Antonio
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера