请教一个问题.请高手帮个忙!!

bb2671168 2010-07-25 11:08:47
card_type char字段
other2 varchar字段

select * from pos_vip_info where convert(int,card_type) > 1

这个可以把这个字段大于1的都显示出来了

select * from pos_vip_info where convert(int,other2) > 1
为什么这个就没有结果


select * from pos_vip_info where convert(int,other2) > 1 and convert(int,card_type) > 1

这个更没有结果,请高手给我说一下这句的正确方法!



...全文
237 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
bb2671168 2010-07-25
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 xys_777 的回复:]
SQL code

create table pos_vip_info
(
card_type char(10),
other2 varchar(10)
)
insert pos_vip_info
select '01','123.5' union all
select '02','15.623' union all
select '03','0.5' union al……
[/Quote]


谢谢高手!!!!!!
永生天地 2010-07-25
  • 打赏
  • 举报
回复

create table pos_vip_info
(
card_type char(10),
other2 varchar(10)
)
insert pos_vip_info
select '01','123.5' union all
select '02','15.623' union all
select '03','0.5' union all
select '04','13.5'

select * from pos_vip_info where convert(int , card_type)>1
/*
card_type other2
---------- ----------
02 15.623
03 0.5
04 13.5

(3 行受影响)*/


select * from pos_vip_info where convert(int , other2)>1
/*
-----------
card_type other2
---------- ----------
消息 245,级别 16,状态 1,第 2 行
在将 varchar 值 '123.5' 转换成数据类型 int 时失败。
*/

select * from pos_vip_info where convert(numeric , other2)>1
/*
card_type other2
---------- ----------
01 123.5
02 15.623
04 13.5

(3 行受影响)

*/
go
drop table pos_vip_info
bb2671168 2010-07-25
  • 打赏
  • 举报
回复
请高手给看看,这个语法上没有错误吧
bb2671168 2010-07-25
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 josy 的回复:]
other2字段有大于1的数据吗?
[/Quote]


有的是都以是 100.125 这样的数,如果没有数就是空的
bb2671168 2010-07-25
  • 打赏
  • 举报
回复
card_type char字段 这里面存的都是 01 02 03 这几个数
other2 varchar字段 这里面存的是 123.4520 这样的小数,还有一些是空的

两个里面都没有数字以外的字符...
百年树人 2010-07-25
  • 打赏
  • 举报
回复
other2字段有大于1的数据吗?
andy_liucj 2010-07-25
  • 打赏
  • 举报
回复
不会执行的时候的错误你也没注意吧,呵呵

34,838

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧