Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic MySQL Tables

Tags:

sql

dynamic

mysql

Is it possible in MySQL to create tables that use other column from another table dynamically (same idea as extending a class in PHP). Example:

table1
    table1_id
    column1
    column2
    column3

table2
    table2_id
    column4
    column5

So when I query table2 I get all the columns from table1 like:

SELECT table1_id,column1,column2,column3,table2_id,column4,column5 FROM table2;
like image 729
Tech4Wilco Avatar asked May 22 '26 19:05

Tech4Wilco


1 Answers

CREATE VIEW t2_view AS <SELECT stuff FROM t1,t2> (not sure exactly how you want to join t1 and t2)

SELECT * FROM t2_view;

Something like that is what you are looking for I think.

like image 82
Ignacio Avatar answered May 24 '26 10:05

Ignacio



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!