Languages
[Edit]
EN

MySQL - create SELECT-JOIN query with column name prefixes

9 points
Created by:
Keisha-Acosta
380

In this article we would like to show how to create MySQL SELECT-JOIN query with column prefixes.

It is imposible to create direct query with column prefixes but there is some trick that let us to generate column names with aliases that can be combined into SELECT-JOIN query.

Note: it is required to have access to `information_schema`.`columns` table.

With this article you will be able to generate your query in following form:

 

Automatic query generator

Edit

In this section you can see example query generator, just set @database, @from_table and @join_tables to see effect.

Example output:

 

Manual query creation

Edit

In this section you can see example query that generates columns that can be used to create query.

Column prefixes can be generated with:

Where: my_database, my_table_1, my_table_2, my_table_3 and my_table_N should be replaced with used database and table names.

Example output:

Created SELECT-JOIN query from example output:

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join