2011-12-22 79 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()