5 回答

TA貢獻2041條經(jīng)驗 獲得超4個贊
直接用> < 啊
比如
select * from 表 where 字段 > 100
---補充
你什么數(shù)據(jù)庫啊。varchar類型也可以用。
create table test(
col1 varchar(2)
)
declare @i int
set @i = 1
while @i< 100
begin
insert into test values(convert(varchar(2),@i))
set @i = @i + 1
end
select * from test where col1 > 50 --正確
select * from test where convert(numeric(10),col1) > 50 --正確
select * from test where col1 > '50' --錯誤
drop table test
你自己測試吧
如果你非要把類型轉成數(shù)值型也可以但這是用不到索引了

TA貢獻1872條經(jīng)驗 獲得超4個贊
可以把varchar轉換成別的類型
比如 decimal,float之類
例:
select * from 表 where convert(float,字段)>100

TA貢獻1779條經(jīng)驗 獲得超6個贊
條件語句
where id != '1' and id != '2' --id字段為char、nchar、varchar型等等
或
where id != 1 and id != 2 --id字段為int、smallint型

TA貢獻1719條經(jīng)驗 獲得超6個贊
查詢的時候加個這個,distincy,舉個例子:$list['pay_user'] = $this->get_table("orders")->where("pay_time>=$time2 and pay_time<$time1 and is_recharge=%d and statu=%d",1,1)->count('DISTINCT username');就這樣,你就可以查出不相同的字段了
添加回答
舉報