join - How to combine a field from multiple tables into a single field in a MySQL View? -


i have multiple tables, each code field. i'd combine values in separate code fields new view in single code field. want distinct code values in view. there codes in each table don't exist in of other tables, , there codes in each table exist in other tables.

what i'm trying fake sql doesn't work:

create view codes select table_a.code code, table_b.code code, table_n.code code table_a, table_b, table_n; 

you need union:

create view codes select code table_a union select code table_b union select code table_n 

please note default, union union distinct: removes duplicates. if want keep them, use union all.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -