0

I'm using joins in MySQL and I would like to make a clear distinction between all the table columns like:

SELECT table.* AS table_reference, table2.* AS table2_reference ...

to have a result like this:

  • table.id
  • table.title
  • table2.id
  • table2.title

is it possible somehow?

Adam Halasz
  • 57,421
  • 66
  • 149
  • 213

2 Answers2

0

Do you mean something like

SELECT table.id
     , table.title
     , table2.id
     , table2.title
FROM table_reference table 
INNER JOIN table2_reference table2 ON table.id = table2.id

You should use aliases that are more descriptive and relevant than table and table2 but I assume that was just for the example.

ethorn10
  • 1,889
  • 1
  • 18
  • 29
0

You have to do it by giving each column its own alias:

select table.id as table_id, table.title as table_title,
       table2.id as table2_id, table2.title as table2_title
from . . .
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786