ABCDEFGHIJKLM是字段名,
求(A、B、C),(D、E、F),(G、H、I、J、K、L、M)三组字段名中各取一个,查询所有的组合

解决方案 »

  1.   


    select * 
    from
    (select a from t
    union all
    select b from t
    union all
    select c from t) t1,
    (select d from t
    union all
    select e from t
    union all
    select f from t) t2,
    (select g from t
    union all
    select h from t
    union all
    select i from t
    union all
    select j from t
    union all
    select k from t
    union all
    select l from t
    union all
    select m from t) t3,
      

  2.   

    感谢老师的关注。我手上一张feature的mysql表,表中有字段名为D1、J1、Z1、L1、Y1;D2、J2、Z2、L2、Y2;D3、J3、Z3、L3、Y3等,我要把他们的字符串数据按照(D1、J1、Z1、L1、Y1)、(D2、J2、Z2、L2、Y2)、(D3、J3、Z3、L3、Y3)三组各取一个,组合起来。通过查询语句把所有的组合都查询出来,我是新手,请老师帮忙。下面的代码是按照您的代码改过来的,测试不成功select * 
    from
    (select D1 from feature
    union all
    select J1 from feature
    union all
    select Z1 from feature
    union all
    select L1 from feature
    union all
    select Y1 from feature) t1,
    (select D2 from feature
    union all
    select J2 from feature
    union all
    select Z2 from feature
    union all
    select L2 from feature
    union all
    select Y2 from feature) t2,
    (select D3 from feature
    union all
    select J3 from feature
    union all
    select Z3 from feature
    union all
    select L3 from feature
    union all
    select Y3 from feature) t3,
      

  3.   

    select * 
    from 
    (select concat(D1,J1,Z1,L1,Y1)
    from feature) as a,
    (select concat(D2,J2,Z2,L2,Y2)
    from feature) as b,
    (select concat(D3,J3,Z3,L3,Y3) 
    from feature)as c