MySQL Display Table Name Along With Columns -
i'm debugging huge mysql call joins large amount of tables share column names such id, created_at, etc. started picking apart wondering if there way like:
select * table.column_name table1 left join etc etc etc...
in place of having individually name columns like:
select table1.`column2' 'name', table1.`column3` ...
it speeding debugging process if there's way it.
thanks.
edit:
thanks answers far. they're not quite i'm looking , think question bit vague i'll give example:
suppose have setup in mysql schema:
table: students fields: int id | int school_id | varchar name
table: schools fields: int id | int name
students contains:
1 | 1 | "john doe"
schools contains:
1 | "imaginary school one"
doing mysql call "select * students left join schools on (students.school_id = schools.id)" yield:
id | school_id | name | id | name 1 | 1 | "john doe" | 1 | "imaginary school one"
we know better , know first id , name columns refer students table , second id , name refer schools table since data set small , unambiguous naming. however, if had deal result set contained multiple left joins , columns similar names, start difficult read , you'd have trace through following joins. start doing like
select school.name 'school_name', etc etc etc...
but gets incredibly impractical once start dealing large data sets.
i wondering though if there way return result set wherein column names instead:
students.id | students.school_id | students.name | schools.id | schools.name
which useful future references if need similar again.
what if select tables in order, , add spacer column name.
i.e.
select 'table1', t1.*, 'table2', t2.*, 'table3', t3.* ...
at least way don't have name specific columns.
Comments
Post a Comment