select c.id,c.id from productclick as c left outer join
productview as v on c.productid=v.productid and v.viewtype=1 and to_days(c.clickdate) = to_days('2009-7-10')
productclick 这个表是产品被点击的信息 productview是表被浏览的信息现在我想查出今天这个表被点击了多少次并且 是productview表中浏览类型viewtype=1的情况下点击的 这样的sql怎么写谢谢
productview as v on c.productid=v.productid and v.viewtype=1 and to_days(c.clickdate) = to_days('2009-7-10')
productclick 这个表是产品被点击的信息 productview是表被浏览的信息现在我想查出今天这个表被点击了多少次并且 是productview表中浏览类型viewtype=1的情况下点击的 这样的sql怎么写谢谢
解决方案 »
- VC中备份数据库
- mysql存储过程中如何把查询的值取出来并赋给自己定义的字段
- Mysql自增找序列在我删除一行后能自动调整序号吗?
- 《PHP和MYSQL WEB开发》第4版 P171页(9.5.5 使用GRANT和REVOKE的例子) 有错 求解
- mysqldump的问题。 请大牛看看!
- ERROR 1172 (42000): Result consisted of more than one row?
- 字符时间比较!!
- windows下安装mysql时总是显示mysql for visual studio1.0.2下载失败,我应该怎么办?
- 有这么一个表,请问怎么写sql做排序?
- MySQL 数据库数据经常丢失
- 一个查询问题
- postgresql实现job?
from productclick as c left outer join productview as v
on c.productid=v.productid
where v.viewtype=1 and to_days(c.clickdate) = to_days('2009-7-10')
http://www.accessbbs.cn/bbs/viewthread.php?tid=19546
看一下这个贴了浪费了多少时间在问题的表达上。
productclick有8条记录 productview有2条记录
为什么我用
select * from productclick c,productview v where c.productid = v.productid
查出16条记录呀下面是表结构
CREATE TABLE `productclick` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`productid` int(11) NOT NULL,
`clicknum` int(11) NOT NULL,
`spent` decimal(13,2) DEFAULT NULL,
`ipaddress` char(50) DEFAULT NULL,
`refererurl` char(200) DEFAULT NULL,
`active` int(11) DEFAULT NULL,
`clickdate` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=14 DEFAULT CHARSET=utf8;CREATE TABLE `ad_bannerview` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`productid` int(11) DEFAULT NULL,
`spent` decimal(13,2) DEFAULT NULL,
`datestamp` char(50) DEFAULT NULL,
`enterdate` datetime DEFAULT NULL,
`viewtype` int(1) DEFAULT NULL,
`keywords` char(100) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=99 DEFAULT CHARSET=utf8;
id
1
1
1
1B
1
1
这样 from a,b where a.id=b.id 当然会产生 4*2 条记录。
4