如上图,我点击搜索,从数据库中对相应的信息进行分类显示,并分页,但我是以编号为关键字,所以按分类搜索后编号是不连续的,所以我的SQL语句一直有问题。
请大神帮帮我,感激不尽!
sqlResult = "(select Top 10* from opinion where (CATEGORY='" + ddlNewsStyle.SelectedValue + "')and (( BODY like '%" + txtKey.Text + "%')or (KEYWORDS like '%" + txtKey.Text + "%'))and(USERID not in(select top " + 10 * CurrentPage + " USERID from opinion order by USERID asc)))order by USERID asc ";
上面是我写的语句。
问题我觉得是在这USERID not in(select top " + 10 * CurrentPage + " USERID from opinion order by USERID asc)))order by USERID asc ";
CurrentPage是当前页。
(CATEGORY='" + ddlNewsStyle.SelectedValue + "')and (( BODY like '%" + txtKey.Text + "%')or (KEYWORDS like '%" + txtKey.Text + "%'))是分类,以及查询框关键字查询的条件。