mysql - How to generate Ordered pairs from a select statement -
i have sites table need generate site_id pairs from. have:
site_id 1 2 3 4
and need generate following result
1 - 2, 1 - 3, 1 - 4, 2 - 3, 2 - 4, 3 - 4
no site can match , either side can 1 of values. have following far.
select a,b (select site_id a, site_id b) sites group a,b;
and
select distinct a,b (select site_id a, site_id b) sites group a,b;
similar question asked here matlab matlab question
any appreciated
something this?
select s1.site_id, s2.site_id site s1 join site s2 on s2.site_id > s1.site_id /* order s1.site_id */
Comments
Post a Comment