2011-12-22 80 views
0

我想加入一個像這樣的解釋性陳述。實際上需要檢索列和列的數據類型存儲在名爲'wyspesific'的另一個表中。是否可以在mysql查詢中左連接explain語句?

select 
st.segnam as Segment, 
st.typnam as 'Sub-Segment', 
group_concat(distinct ws.fldnam) as 'Field Tag Name (database)', 
group_concat(distinct ws.fldcap) as 'Field Name Label', 
concat('(', group_concat(distinct of.optcap order by of.optcap desc),')') as optionFieldLabel, 
concat('(', group_concat(distinct of.optval order by of.optcap desc),')') as optionFieldValue, 
ws.isopt as isOptionField 
from shiptype st 
left join wyspecific ws on ws.wytypid = st.wytypid and ws.enabled = 'Y' 
left join optionfields of on of.fldnam = ws.fldnam and of.deleted = 'N' 
left join (explain shipspecific) as v on ws.fldnam = v.Field 
where st.segid in(6,4,8,9,10,11,12) and ws.enabled = 'Y' 
group by ws.fldid 
order by st.segid 

任何建議或想法將不勝感激。

非常感謝。

回答

2

您應該INFORMATION_SCHEMA.COLUMNS,而不是拉這樣的信息:

SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='shipspecific' AND TABLE_SCHEMA=DATABASE()