formulahendry / vscode-mysql

MySQL management tool for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=formulahendry.vscode-mysql
MIT License
221 stars 60 forks source link

Selecting and joining tables where columns have the same name #154

Open Jemmy350 opened 4 years ago

Jemmy350 commented 4 years ago

So if I have two tables for example that both have name, when selecting and joining these two the second table name overwrites the first.

select recipes.id, recipes.name, recipes.prep_time, recipes.main_ingredient, ingredients.name from recipes join ingredients on recipes.main_ingredient = ingredients.id;

ingredients id name category calories unit
1 apple fruit 50 item
2 peach fruit 50 item
3 chicken poultry 95 oz
recipes id name prep_time main_ingredient
1 Chicken Alfredo 30 3
result id name prep_time main_ingredient
1 chicken 30 3
expected id name prep_time main_ingredient name
1 Chicken Alfredo 30 3 chicken
Hugo-Matias commented 2 years ago

Experiencing similar behavior however, instead of displaying just the single column it's showing both columns but the values are from the first field that has conflicting name. Taking your example it would show like so:

id | name | prep_time | main_ingredient | name 1 | Chicken Alfredo | 30 | 3 | Chicken Alfredo