I am assuming that you actually want to list all columns of the tables involved in a join.
There is a neat trick to view the qualified table and column names in a select statement. First EXPLAIN
the select query, then look at the result of SHOW WARNINGS
:
EXPLAIN SELECT * FROM users JOIN posts ON users.id = posts.user_id;
SHOW WARNINGS;
The result will look something like this:
Level |
Code |
Message |
Note |
1003 |
/* select#1 */ select `testdb`.`users`.`id` AS `id`,`testdb`.`users`.`name` AS `name`,`testdb`.`posts`.`id` AS `id`,`testdb`.`posts`.`user_id` AS `user_id`,`testdb`.`posts`.`name` AS `name` from `testdb`.`users` join `testdb`.`posts` where (`testdb`.`users`.`id` = `testdb`.`posts`.`user_id`) |
The resulting query contains fully qualified name of all columns inside the select clause instead of *
.