瀟瀟雨雨
2018-12-03 14:08:11
P> 我要獲取日志表的內(nèi)容,條件是根據(jù)標(biāo)簽來(lái)獲取,不知道怎么寫(xiě)了.請(qǐng)幫忙</P> <P> 表一: [blog_Content] 日志表: </P> <P>字段:blog_id ,cate_Id,blog_Title,blog_Entry,blog_Content,blog_Tbs 等</P> <P> 表二: [blog_tag] 標(biāo)簽表:</P> <P>字段:tag_Id,tag_Label,tag_Used</P> <P> 表三: [blog_Blogtag] 關(guān)聯(lián)表:</P> <P>字段:seq_Id,blog_Id,tag_Id</P> <P> 比如.我根據(jù)分類(lèi)來(lái)獲取日志列表就是這樣寫(xiě): 因?yàn)樵谝粋€(gè)表中</P> <P> "select * from blog_Content where <A href="mailto:cate_id=@CataID">cate_id=@CataID</A> ";</P> <P> </P>問(wèn)題補(bǔ)充: /// <summary> /// 獲取文章列表 根據(jù)分類(lèi) /// </summary> /// <param name="CreateUser"></param> /// <returns></returns> public override IList<Content> GetTopContent(int CatId) { string strGetTopContent = "SELECT * FROM blog_Content where Cat_id=@CatId"; IDataReader dr = SQLiteHelper.ExecuteReader(strGetTopContent, null); IList<Content> list = new List<Content>(); while (dr.Read()) { list.Add(Model(dr)); } dr.Close(); return list; }
2 回答

ibeautiful
TA貢獻(xiàn)1993條經(jīng)驗(yàn) 獲得超6個(gè)贊
根據(jù)標(biāo)簽ID獲取日志: select * from [blog_Content] where blog_id in (select blog_id from blog_Blotag where tag_Id=@tagId) 根據(jù)標(biāo)簽獲取日志: select * from [blog_Content] where blog_id in (select blog_id from blog_Blotag where tag_Id=(select tag_Id from blog_tag where tag_label=@taglabel))

倚天杖
TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超3個(gè)贊
select bc.* from blog_Content bc,[blog_tag] bt,[blog_Blogtag] bbt where bt.tag_Label="...." and bt.tag_Id = bbt.tag_Id and bbt.blog_Id = bc.blog_Id
- 2 回答
- 0 關(guān)注
- 700 瀏覽
添加回答
舉報(bào)
0/150
提交
取消