读书人

小弟我又来纠结一条基础的SQL语句了

发布时间: 2013-03-25 15:43:04 作者: rapoo

我又来纠结一条基础的SQL语句了
本帖最后由 wangxuebo 于 2013-03-23 11:01:06 编辑 type表

typeid typename parentid
1 水果 0
2 葡萄 1
3 香蕉 1

content表
id btype stype
1 1 3

查询出结果

1 水果 香蕉
[解决办法]

select a.typename,b.typename from content 
join [type] a
on a.typeid=content.btype
join [type] b
on b.typeid =content.stype

读书人网 >asp.net

热点推荐