select count(*) from a inner join b on a.id=b.id and b.price>800;这样得到2.select a.name from a inner join b on a.id=b.id and b.price>800;这样得到名称。
select count(*) from hotel A,house B where A.title like '南昌' and A.id = B.hotelid and B.weekmprice<300 select A.id ,A.title from hotel A,house B where A.title like '南昌' and A.id = B.hotelid and B.weekmprice<300
SQL运行之后,得不到2,得不出宾馆名
提出你的SHOW CREATE TABLE,还有INSERT语句。。别人好给你做测试。
select a.title from shop_ccms_hotel a ,shop_ccms_house b where a.id = b.hotelid and b.title like '南昌%' and b.weekprice<300 group by a.title 这是有人写的,代码,可以取出宾馆名字
select count(a.title) from shop_ccms_hotel a ,shop_ccms_house b where a.id = b.hotelid and b.title like '南昌%' and b.weekprice<300 group by a.title
select count(*) from a inner join b on a.id=b.id and b.price>800;这样得到2.select a.name from a inner join b on a.id=b.id and b.price>800;这样得到名称。
from hotel A,house B
where A.title like '南昌' and A.id = B.hotelid and B.weekmprice<300
select A.id ,A.title
from hotel A,house B
where A.title like '南昌' and A.id = B.hotelid and B.weekmprice<300
where a.id = b.hotelid and b.title like '南昌%' and b.weekprice<300
group by a.title
这是有人写的,代码,可以取出宾馆名字
where a.id = b.hotelid and b.title like '南昌%' and b.weekprice<300
group by a.title
建议你列出你的表结构,并提供测试数据以及基于这些测试数据的所对应正确结果。
参考一下这个贴子的提问方式http://topic.csdn.net/u/20091130/20/8343ee6a-417c-4c2d-9415-fa46604a00cf.html
1. 你的 create table xxx .. 语句
2. 你的 insert into xxx ... 语句
3. 结果是什么样,(并给以简单的算法描述)
4. 你用的数据库名称和版本(经常有人在MS SQL server版问 MySQL)
这样想帮你的人可以直接搭建和你相同的环境,并在给出方案前进行测试,避免文字描述理解上的误差。