sql - replicate table 1 and combine a value from table2 -



sql - replicate table 1 and combine a value from table2 -

i have table1 this:

and other column in table2 having 2 unique value 3 , 4. how write query create table

actually table more complicated 1 above: tried :

"select distinct table1.x, table1.y ,table2.z table1 table1.a = "something' , table1.b not null, cross bring together table2 table2.z='something' or table2.z='something2' "

it not work...i using modeling bundle utilize sql language , not sure compatible sql.

you looking find cartesian product of 2 tables. can short as:

select * table1, table2;

or explicitly using cross join as:

select table1.*, table2.* table1 cross bring together table2;

to filter each table individually, can utilize sub-queries:

select distinct table1.x, table1.y, table2.z (select * table1 table1.a = 'something' , table1.b not null ) table1 cross bring together (select * table2 table2.z = 'something' or table2.z = 'something2' ) table2;

or utilize combine logic under 1 query:

select distinct table1.x, table1.y, table2.z table1, table2 table1.a = 'something' , table1.b not null , (table2.z = 'something' or table2.z = 'something2')

sql

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -