sql - Can you have a foreign table name like a foreign key? -
i'm playing ideas. want foreign key want table key should used in row. foreign keys can refer different tables. you'd returning 1 result given query needed dereference 'pointer'.
i know store table name , use 2 select statements it, inserting result of first select table , key next call index right table, can done single select on database? sql like?
edit: let me see if can come example. mediatable id | name | owner| type | fkey
mp3 id | artist | album | title | bitrate | codec | data
movie id | title | resolution | imdburl | audiocodec | videocodec | data
ok contrived ... leta want search mediatable titles (in mp3 or movie tables) mediatable.owner = "ekl" assuming fkey foreign key of id field. can "mediatable.type" select table fkey should apply to?
yes, know not best way particular example, easier explaining 2 larger projects want this.
basically, want parameterise foreign key , add table refer.
theoretically, can done string concatenating query , executing in 1 go. but, fetching component strings might need multiple calls or procedure call.
even though theoretically possible, i'd warn that, you're trying extremely unconventional , leads code being slow (due string concatenation) , non-maintainable.
Comments
Post a Comment