找回密码
 注册

QQ登录

快捷登录

新浪微博登陆

搜索
CDD 法语助手

有谁熟悉数据库查询的,问个语句

14
回复
1389
查看
[ 复制链接 ]
头像被屏蔽

新浪微博达人勋

提示: 该帖被管理员或版主屏蔽
2009-11-23 11:08:53

新浪微博达人勋

数据库里已经有的数据是怎么样的?
2009-11-23 11:23:04

使用道具 举报

新浪微博达人勋

你认不认识人 作soft phone?
2009-11-23 11:23:33

使用道具 举报

新浪微博达人勋

你认不认识人 作soft phone?
吴哥 发表于 23/11/2009 11:23


我办公室旁边的人就是,2个iphone,1个android还都是autoentrepreneur

1天facturer,600欧
你要需要,我给你问问
   
2009-11-23 11:26:04

使用道具 举报

新浪微博达人勋

数据库里已经有的数据是怎么样的?
booker 发表于 23/11/2009 11:23



   是这样的

  1. CREATE TABLE IF NOT EXISTS `la_comment` (

  2.   `comment_id` int(11) NOT NULL auto_increment,
  3.   `user_id` int(11) NOT NULL default '0',
  4.   `create_date` int(11) NOT NULL default '0'
  5.   PRIMARY KEY  (`comment_id`),
  6.   KEY `user_id` (`user_id`)
  7. ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=361377 ;
复制代码



我简化一下

然后,我要比如说今天,user_id=10的回复总数,和user_id<>10的回复总数
但是一个sql出来的

我已经用2个做完了,如果有1个能搞定的方法,更好。谢
2009-11-23 11:31:48

使用道具 举报

头像被屏蔽

新浪微博达人勋

提示: 作者被禁止或删除 内容自动屏蔽
2009-11-23 11:32:06

使用道具 举报

头像被屏蔽

新浪微博达人勋

提示: 作者被禁止或删除 内容自动屏蔽
2009-11-23 11:46:51

使用道具 举报

新浪微博达人勋

我可能没看懂,
用一个union 不就可以了么
asingfr 发表于 23/11/2009 11:46


要结果是一行 date nb_user_10 nb_user_others
不是2行
   
2009-11-23 11:49:33

使用道具 举报

新浪微博达人勋

本帖最后由 booker 于 2009-11-23 12:13 编辑

SELECT  DISTINCT date,
            (select Count(comment_id) from la_comment where comment_id=10 and date=date1) AS nb_user_10,
            (select Count(comment_id) from la_comment where comment_id=<>10 and date=date1) AS nb_user_others
FROM la_comment
WHERE date=date1
参与人数 1声望 +25 战斗币 +60 收起 理由
doodoo_hu + 25 + 60 这哥们口袋里的zdb也忒少了点

查看全部评分总评分 : 声望 +25 战斗币 +60

2009-11-23 12:03:38

使用道具 举报

新浪微博达人勋

测试了一下,似乎可以。不过我用的是SqlServer。你用的是MySql吧?
2009-11-23 12:04:27

使用道具 举报

新浪微博达人勋

SELECT  DISTINCT date,
            (select Count(comment_id) from la_comment where comment_id=10 and ...
booker 发表于 23/11/2009 12:03


是的,我刚才搞定了。和你的其实一样。我用的是mysql。同样谢谢了
   
  1. SELECT DATE(FROM_UNIXTIME(`create_date`)) as `date`, count(comment_id) as nb, (
  2. select count(comment_id) as nb1 FROM `la_comment` b
  3. WHERE b.`user_id` != 10
  4. AND DATE(FROM_UNIXTIME(b.`create_date`)) = DATE(FROM_UNIXTIME(a.`create_date`))
  5. ) as nb1 FROM `la_comment` a WHERE a.`user_id` = 10
  6. group by DATE(FROM_UNIXTIME(a.`create_date`))
复制代码
2009-11-23 12:20:57

使用道具 举报

新浪微博达人勋

回复 4# 伶俜

给我一下,谢谢。
2009-11-23 12:28:15

使用道具 举报

头像被屏蔽

新浪微博达人勋

提示: 作者被禁止或删除 内容自动屏蔽
2009-11-23 13:03:37

使用道具 举报

新浪微博达人勋

我给你短信
2009-11-23 13:04:53

使用道具 举报

新浪微博达人勋

啊。。。进错贴了。。。闪
2009-11-23 13:44:22

使用道具 举报

您需要登录后才可以回帖 登录 | 注册 新浪微博登陆

本版积分规则

返回顶部