使用Order By进行SQL查询 [英] sql query using Order By

查看:136
本文介绍了使用Order By进行SQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

{
       Sql = "select * from BirthDayWish where Active = 'A'";
       Dr = SCon.ReadSql(Sql);
       GridView1.DataSource = Dr;
       GridView1.DataBind();
       GridView1.Visible = true;
   }







在上面的sql查询中。




in the above sql query.

Sql = "select * from BirthDayWish where Active = 'A'";



i想要使用OrderBy名称。



如何使用。



i我使用以下查询,这是正确的。




i want to use OrderBy Name.

how to use.

i am using the below query,this is correct.

sql="select * from BirthDayWish OrderBy Name where Active='A'";





上述查询是正确的。





pleae帮助我。并发送查询;



the above query is correct.


pleae help me.and send the query;

推荐答案

排序方式 [ ^ ]子句来自Where子句。

所以你的查询应该是

Order By[^] Clause comes after Where clause.
So your query should be
select * from BirthDayWish where Active='A' Order By [Name] 


如果指定要获取的所有列,那将会好得多:



sql =选择Id,姓名,活跃于BirthDayWish WHERE Active =''A''按名称排序ASC;
Hi it would be much better if specify all columns that you want to fetch:

sql="select Id,Name,Active from BirthDayWish WHERE Active=''A'' Order By Name ASC";


{
 Sql = "select * from BirthDayWish where Active = 'A'";
 Dr = SCon.ReadSql(Sql);
 Dr.DefaultView.Sort = "Name ASC";
 GridView1.DataSource = Dr;
 GridView1.DataBind();
 GridView1.Visible = true;
 }


这篇关于使用Order By进行SQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆