这个怎么判断啊,似乎少了个字段吧, pho priceL priceH num a 3100 6000 1 b 2900 5800 2 c 2800 5600 3 d 2400 5100 4 没数量怎么判断呢?
a b c d 分别是四个手机的价格范围。 不是 四类 手机。 比如 a是 诺基亚6120c ,厂家没有定价格。给了个范围。 b是 诺基亚6500 ,厂家也没有定价格。给了个范围。
1、查询 3000-4000 的手机最多可能有几个? select count(*) from table1 where priceL<=4000 and priceH>=3000
第2条和第1条没什么区别,把数改一下而已3、查询 最低价大于2000的手机最多可能有几个? select count(*) from table1 where priceL>20004.查询 最高不超过6000的手机可能有几个? select count(*) from table1 where priceH<=6000
select count(*) from table1 where priceL <=4000 and priceH>=3000 这样写呢? 还是如下写呢? select count(*) from table1 where priceH <=4000 and priceL>=3000你觉得这样最多会有几个手机呢?两种写法 会有什么结果呢?就具体到本例中来。 第一种写法,一个结果页没有。 第二种写法,只有一个结果。a 但实际上,3000-4000 的手机,最多可能会有四个。 a b c d 的手机价格假如都是3500 ,这样,一方面,都处于其价格区间之间,另一方面,也都处于3000-4000之间。pho priceL priceH a 3100 6000 b 2900 5800 c 2800 5600 d 2400 5100
不知道你有什么问题? 单说a 3100 6000 吧,你自己简单替换一下不知道了吗? select count(*) from table1 where priceL <=4000 and priceH>=3000 按上面记录替换 select count(*) from table1 where 3100 <=4000 and 6000>=3000 明显是成立的,何来一条都没有的说法?
对。你说的对。应该是这样。 select count(*) from table1 where priceL <=4000 and priceH>=3000 那1000-8000之间也这么查嘛? select count(*) from table1 where priceL <=8000 and priceH>=1000
应该是这样来写的1.SELECT * FROM test where (priceL<=3000 and priceH>=3000) or (priceL<=4000 and priceH>=4000) or (priceL>3000 and priceH<4000)2.SELECT * FROM test where (priceL<=1000 and priceH>=1000) or (priceL<=8000 and priceH>=8000) or (priceL>1000 and priceH<8000) 你可以去这里看下http://bbs.blueidea.com/viewthread.php?tid=2938353&pid=4617867&page=1&extra=page%3D1#pid4617867
pho priceL priceH num
a 3100 6000 1
b 2900 5800 2
c 2800 5600 3
d 2400 5100 4
没数量怎么判断呢?
b
c
d
分别是四个手机的价格范围。
不是 四类 手机。
比如 a是 诺基亚6120c ,厂家没有定价格。给了个范围。
b是 诺基亚6500 ,厂家也没有定价格。给了个范围。
select count(*) from table1 where priceL<=4000 and priceH>=3000
select count(*) from table1 where priceL>20004.查询 最高不超过6000的手机可能有几个?
select count(*) from table1 where priceH<=6000
还是如下写呢?
select count(*) from table1 where priceH <=4000 and priceL>=3000你觉得这样最多会有几个手机呢?两种写法 会有什么结果呢?就具体到本例中来。
第一种写法,一个结果页没有。
第二种写法,只有一个结果。a
但实际上,3000-4000 的手机,最多可能会有四个。 a b c d 的手机价格假如都是3500 ,这样,一方面,都处于其价格区间之间,另一方面,也都处于3000-4000之间。pho priceL priceH
a 3100 6000
b 2900 5800
c 2800 5600
d 2400 5100
单说a 3100 6000 吧,你自己简单替换一下不知道了吗?
select count(*) from table1 where priceL <=4000 and priceH>=3000
按上面记录替换
select count(*) from table1 where 3100 <=4000 and 6000>=3000
明显是成立的,何来一条都没有的说法?
select count(*) from table1 where priceL <=4000 and priceH>=3000 那1000-8000之间也这么查嘛?
select count(*) from table1 where priceL <=8000 and priceH>=1000
你可以去这里看下http://bbs.blueidea.com/viewthread.php?tid=2938353&pid=4617867&page=1&extra=page%3D1#pid4617867