select msg from cpzq where id in (select max(id) as id --<----how about add this from cpzq)
select max(id) from cpzq 这个子查询能不能返回最大ID?使用语句: select msg from cpzq where id = (select max(id) id from cpzq) or select msg from cpzq where id in (select max(id) id from cpzq)
to xx9yk and thing 都不行
我的是 ORACLE 语法, xx9yk的是 SQL SERVER
你的 select max(id) from cpzq 能不能返回最大值
select msg from cpzq where id = (select max(id) as id from cpzq)
作个转换把 select msg from cpzq where to_number(id) in (select max(to_number(id)) from cpzq) //to_number是一个字符转换为数字的函数,不知道你用的数据库是什么,不过也应该有类似的函数
你用 CAST 或 CONVERT 把ID转换成数字型的进行比较,这两个函数我不太会用(我用ORACLE, 和楼上一样:))。select msg from cpzq where cast(id as int) = (select max(cast(id as int)) from cpzq)
谢谢,可以了 select msg from cpzq where (CAST( id AS int(4))) in (select max (CAST(id AS int(4))) from cpzq)
from cpzq
where id in
(select max(id) as id --<----how about add this
from cpzq)
select msg from cpzq where id = (select max(id) id from cpzq)
or
select msg from cpzq where id in (select max(id) id from cpzq)
xx9yk的是 SQL SERVER
select msg from cpzq where to_number(id) in (select max(to_number(id)) from cpzq)
//to_number是一个字符转换为数字的函数,不知道你用的数据库是什么,不过也应该有类似的函数
select msg from cpzq where
(CAST( id AS int(4))) in (select max (CAST(id AS int(4))) from cpzq)