SQL 问题

[复制链接]
查看11 | 回复4 | 2011-6-29 09:12:34 | 显示全部楼层 |阅读模式
现有表A如下:
id
title
num
sum
1
北京
1
0
2
武汉
2
0
3
南京
2
2
4
上海
1
0
5
重庆
1
0
现在需要查询 num=1 并且sum =0的所有 数据 并且返回结果排序为order by id asc
这个SQL语句该怎么写 小白求教
string sql = "select *from Columns where Column_ids =" + id + "and Channel_id=" + Channel_id + " order by Column_id ase";
提示ase 附近有语法错误 Column_ids id Channel_id Column_id 均为int型

回复

使用道具 举报

千问 | 2011-6-29 09:12:34 | 显示全部楼层
select * from 表名 where num=1 and sum=0 order byn id asc把表名换成你要的表名就可以...
回复

使用道具 举报

千问 | 2011-6-29 09:12:34 | 显示全部楼层
string sql = "select * from Columns where Column_ids =" + id + " and Channel_id=" + Channel_id + " order by Column_id asc";注意空格,上面报的语法错误是因为你写错单词了。升序是asc,降序是desc...
回复

使用道具 举报

千问 | 2011-6-29 09:12:34 | 显示全部楼层
select* from A where num=1 and sum=0 order by id asc...
回复

使用道具 举报

千问 | 2011-6-29 09:12:34 | 显示全部楼层
string sql = "select * from Columns where Column_ids =" + id + " and Channel_id=" + Channel_id + " order by Column_id asc";...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行