0

I have this query

SELECT
      table_1.*,
      table_2.*
FROM 
     .....

Table 1 and table 2 both have the same column names:

ID
Value

What I want to do is something like

SELECT
      table_1.* AS 'prefix_1_'.*,
      table_2.* AS 'prefix_2_'.*
FROM 
     .....

So I would end up with:

array(prefix_1_ID = X, prefix_1_Value = X, prefix_2_ID = Y, prefix_2_Value = Y)

Is this possible?

user783322
  • 479
  • 1
  • 8
  • 19
  • This is not possible to my knowledge. – mechanical_meat Mar 30 '17 at 21:39
  • You will have to list out all of the columns and add an alias for each one that matches that format. – JNevill Mar 30 '17 at 21:40
  • I'd be extremely surprised if this were possible. Also even if it were you'd probably be better off not doing it: http://stackoverflow.com/questions/3639861/why-is-select-considered-harmful – gandaliter Mar 30 '17 at 21:40
  • Would be a nice feature, feel free to suggested in the mysql forum. Right now you have to type it. – Juan Carlos Oropeza Mar 30 '17 at 21:45
  • I don't think that this is a duplicate. The answer in the other question requires that I specify all of the columns that I want to append to, iterate through them, and append appropriately. This question was about 'globally' appending to all columns in `table`.`*` – user783322 Mar 30 '17 at 22:11

0 Answers0