It’s possible to find a table name by an id?
I have multiple tables that extends another table, when I find the id in the “super” table, I’d like to know in which subtable is that id.
There is a way with indexing to do that or another way?
Thanks
It’s possible to find a table name by an id? I have multiple tables
Share
Your example is really unclear but …
article(stuff,id)
news(id references article(id),morestuff)
courses(id references article(id),evenmorestuff)
So you’re using the id from article to link to either news or courses and would like to avoid select union from news AND courses ?
1) your current query does not contain this information
2) A few ways to do this:
a) you change your datamodel to something more generic (article,r_article_news,news,r_article_courses,courses) and determine that on this basis
b) you add the information in the article table (add a column named type, where you will enter either news or courses)
c) you make your first query slightly heavier to determine that automatically