title: SQL select join: is it possible to prefix all columns as 'prefix.*'?
body: <p>I'm wondering if this is possible in SQL. Say you have two tables A and B, and you do a select on table A and join on table B:</p>
  <pre><code>SELECT a.*, b.* FROM TABLE_A a JOIN TABLE_B b USING (some_id);
  </code></pre>
  <p>If table A has columns 'a_id', 'name', and 'some_id', and table B has 'b_id', 'name', and 'some_id', the query will return columns 'a_id', 'name', 'some_id', 'b_id', 'name', 'some_id'. Is there any way to prefix the column names of table B without listing every column individually? The equivalent of this:</p>
  <pre><code>SELECT a.*, b.b_id as 'b.b_id', b.name as 'b.name', b.some_id as 'b.some_id'
  FROM TABLE_A a JOIN TABLE_B b USING (some_id);
  </code></pre>
  <p>But, as mentioned, without listing every column, so something like:</p>
  <pre><code>SELECT a.*, b.* as 'b.*'
  FROM TABLE_A a JOIN TABLE_B b USING (some_id);
  </code></pre>
  <p>Basically something to say, &quot;prefix every column returned by b.* with 'something'&quot;. Is this possible or am I out of luck?</p>
  <h3>EDITS</h3>
  <p>Advice on not using <code>SELECT *</code> and so on is valid advice but not relevant in my context, so please stick to the problem at hand -- is it possible to add a prefix (a constant specified in the SQL query) to all the column names of a table in a join?</p>
  <p>My ultimate goal is to be able to do a <code>SELECT *</code> on two tables with a join, and be able to tell, from the names of the columns I get in my result set, which columns came from table A and which columns came from table B. Again, I don't want to have to list columns individually, I need to be able to do a <code>SELECT *</code>.</p>