有可能在mysql查询中留下join join语句吗?

时间:2011-12-22 13:19:55

标签: mysql join left-join

我想加入像这样的解释声明。实际上,需要检索列和列的数据类型存储在另一个名为“wyspesific”的表中。

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

非常感谢任何建议或想法。

非常感谢。

1 个答案:

答案 0 :(得分:2)

您应该从INFORMATION_SCHEMA.COLUMNS提取此信息:

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