ABCDEFGHIJKLM是欄位名,
求(A、B、C),(D、E、F),(G、H、I、J、K、L、M)三組欄位名中各取一個,查詢所有的組合
uj5u.com熱心網友回復:
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,
uj5u.com熱心網友回復:
結帖率:0%uj5u.com熱心網友回復:
感謝老師的關注。我手上一張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,
uj5u.com熱心網友回復:
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
uj5u.com熱心網友回復:
怎么回事呢?
uj5u.com熱心網友回復:
謝謝關注,結不了貼,總說分數不對20+20不對40+0不對10+10+20也不對轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/113847.html
標籤:MySQL
