SQL select join: is it possible to prefix all columns as 'prefix.*'? -
i'm wondering if possible in sql. have 2 tables , b, , select on table , join on table b:
select a.*, b.* table_a join table_b b using (some_id); if table has columns 'a_id', 'name', , 'some_id', , table b has 'b_id', 'name', , 'some_id', query return columns 'a_id', 'name', 'some_id', 'b_id', 'name', 'some_id'. there way prefix column names of table b without listing every column individually? equivalent of this:
select a.*, b.b_id 'b.b_id', b.name 'b.name', b.some_id 'b.some_id' table_a join table_b b using (some_id); but, mentioned, without listing every column, like:
select a.*, b.* 'b.*' table_a join table_b b using (some_id); basically say, "prefix every column returned b.* 'something'". possible or out of luck?
thanks in advance help!
edit: advice on not using select * , on valid advice not relevant in context, please stick problem @ hand -- possible add prefix (a constant specified in sql query) column names of table in join?
edit: ultimate goal able select * on 2 tables join, , able tell, names of columns in result set, columns came table , columns came table b. again, don't want have list columns individually, need able select *.
i see 2 possible situations here. first, want know if there sql standard this, can use in general regardless of database. no, there not. second, want know regard specific dbms product. need identify it. imagine answer you'll "a.id, b.id" since that's how you'd need identify columns in sql expression. , easiest way find out default is, submit such query , see back. if want specify prefix comes before dot, can use "select * my_alias", instance.
Comments
Post a Comment