新手求一段数据库查询代码

来源:百度知道 编辑:UC知道 时间:2024/07/02 23:49:08
现在有ACCESS表内 年龄列 名为"age" 都是准确年龄 比如22 23 27 查询是在比如22-25岁一个年龄查询 改怎么写啊

如果是查数字型的语法应该是
sql="select * from shuju where id=数字"
如果是变量应该是
sql="select * from shuju where id="&变量
如果是字符串型的应该是
sql="select * from shuju where 列名='字符串'"
字符串变量
sql="select * from shuju where 列名='"&字符串变量&" '
查询询日期的语法应该是
sql="select * from shuju where 列名=#日期#"
如果是日期变量
日期变量=#2007-11-19# '此处不可少#号
sql="select * from typecontent where 列名=#"&日期变量&"#"

你的age是int类型
查询22到25岁的:select * from table(你的表) where age between 22 and 25
分别查询某个年龄,如查23,11,16,19岁的:
select * from table(你的表) where age in(23,11,16,19) 把你要查询的年龄加在in后面的括号里

还有什么问题我们可以再交流,我的QQ:20505515
这个答案OK吧,楼主

select * from table
where age in(22,23,27)

select * from table
where age >=22 and age <=25

select * from table where age between 22 and 25