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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -