mysql - view with all possible combinations between two tables -


i need view between 2 tables, id's , possible combinations between them without repeat. tables , data:

create table `ta` (     `id` int(11) not null auto_increment,     `name` varchar(50) null default null,     primary key (`id`) )  insert `ta` (`id`, `name`) values (1, 'ta1'); insert `ta` (`id`, `name`) values (2, 'ta2'); insert `ta` (`id`, `name`) values (3, 'ta3'); insert `ta` (`id`, `name`) values (4, 'ta4');   create table `tb` (     `id` int(11) not null auto_increment,     `name` varchar(50) null default null,     primary key (`id`) )  insert `tb` (`id`, `name`) values (1, 'tb1'); insert `tb` (`id`, `name`) values (2, 'tb2'); 

results want in view:

view_rel_taxtb id_a,id_b 1,1 2,1 3,1 4,1 1,2 2,2 3,2 4,2 

here query !

 mysql> select a.id id_a,b.id id_b ta         -> cross join tb b;     +------+------+     | id_a | id_b |     +------+------+     |    1 |    1 |     |    1 |    2 |     |    2 |    1 |     |    2 |    2 |     |    3 |    1 |     |    3 |    2 |     |    4 |    1 |     |    4 |    2 |     +------+------+     8 rows in set (0.00 sec) 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -