Http://www.cnblogs.com/sadier/archive/2004/11/18/65170.html Requirements: An article Table: There is a PostID, ParentId, SourceId (associated) an article)
I originally written a statement and I can't run. SELECT PKID, Title, Author, OperateDate, Text, PostID, ParentID, PostID AS SortIDFROM TBL_PostWHERE (ParentID = 2) AND (PostType = 3 OR PostType = 7) AND (DeleteFlag = 0) UNIONSELECT posta.PKID, posta.Title, posta .Author, posta.OperateDate, posta.Text, posta.PostID, posta.ParentID, postb.PostID AS SortIDFROM tBL_Post posta INNER JOIN tBL_Post postb ON posta.PostID = postb.SourceIDWHERE posta.ParentID = 2 AND posta.DeleteFlag = 0 AND Postb.parentId = 2 and postb.deleteflag = 0order by SortID
Think of DataSet. Merge, as follows
DataSet ds = new DataSet (); string strSQL = String.Format (@ "select TBL_Config.BlogID ID, TBL_Config.Author Name from TBL_Post, TBL_Config where TBL_Post.Operater = TBL_Config.BlogID and PostID = {0} And TBL_Config.BlogID> 2 ", postid; dataable dt = jumpdbprovider.select (strsql);
Dt.primaryKey = New Datacolumn [1] {dt.columns ["id"]}; dt.tables.add (dt.copy ());
strSQL = String.Format (@ "select GroupID ID, GroupName Name from TBL_Group, TBL_PostRight where TBL_PostRight.TempID = TBL_Group.GroupID And IsGroup = 1 and PostID = {0} AND Active = 1", postID); DataTable dtm = JumpDbProvider. SELECT (STRSQL);
DS.MERGE (DTM, False, MissingsChemaAction.add);
Return ds.tables [0];