获取表中某一列的值出现的次数
来源:互联网 发布:ubuntu卸载qq2012 编辑:程序博客网 时间:2024/06/07 01:54
有一张商品表,具体如下:
/*表: product*/----------------/*列信息*/-----------Field Type Collation Null Key Default Extra Privileges Comment ------------------- ------------- --------------- ------ ------ ------------------- --------------------------- ------------------------------- ------------------------------------------------------------------------productId int(11) (NULL) NO PRI (NULL) auto_increment select,insert,update,references brandId int(11) (NULL) YES MUL (NULL) select,insert,update,references 产品所属的品牌 userId int(11) (NULL) YES MUL (NULL) select,insert,update,references 卖家的Id name varchar(256) utf8_general_ci YES (NULL) select,insert,update,references isShowInventory tinyint(4) (NULL) YES (NULL) select,insert,update,references 前如页面是否显示库存:0=不显示,1=显示 imageUrls varchar(2048) utf8_general_ci YES (NULL) select,insert,update,references 商品图片多个以逗号隔开,循序同前台一样 description longtext utf8_general_ci YES (NULL) select,insert,update,references 详细描述 keyWord varchar(256) utf8_general_ci YES (NULL) select,insert,update,references 关键词,搜索用 status tinyint(4) (NULL) YES (NULL) select,insert,update,references 状态:1=草稿,2=待审核,3=审核通过,4=审核不通过 remark varchar(512) utf8_general_ci YES (NULL) select,insert,update,references 审核不通过原因 createTime timestamp (NULL) NO 0000-00-00 00:00:00 select,insert,update,references updateTime timestamp (NULL) NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP select,insert,update,references sellType tinyint(4) (NULL) YES 1 select,insert,update,references 售卖类型:1=普通,2=预售,3=抢购,4=团购,5=分期送 preDeliveryTime timestamp (NULL) YES (NULL) select,insert,update,references 预发货时间 recommendedReason varchar(500) utf8_general_ci YES (NULL) select,insert,update,references 推荐理由 hits int(11) (NULL) YES 0 select,insert,update,references 点击量 productProp varchar(500) utf8_general_ci YES (NULL) select,insert,update,references 商品属性集合 coverPicture varchar(500) utf8_general_ci YES (NULL) select,insert,update,references 封面图片 aliasName varchar(600) utf8_general_ci YES (NULL) select,insert,update,references 商品前台显示名称 rushQuantity int(11) (NULL) YES (NULL) select,insert,update,references 抢购数量 checkTime timestamp (NULL) NO 0000-00-00 00:00:00 select,insert,update,references 审核通过时间(发布时间) operator int(11) (NULL) YES 0 select,insert,update,references 操作人 operationTime timestamp (NULL) NO 0000-00-00 00:00:00 select,insert,update,references 操作时间 manufacturer varchar(100) utf8_general_ci YES select,insert,update,references 生产商 manufacturerAddress varchar(100) utf8_general_ci YES select,insert,update,references 生产地址 manufactureLicence varchar(50) utf8_general_ci YES select,insert,update,references 生产许可证 expiryDate timestamp (NULL) NO 0000-00-00 00:00:00 select,insert,update,references 有效期 productCode varchar(50) utf8_general_ci YES (NULL) select,insert,update,references 产品标准号 barCode varchar(50) utf8_general_ci YES (NULL) select,insert,update,references 条码 isOrganic varchar(1) utf8_general_ci YES (NULL) select,insert,update,references 是否有机 isAdditives varchar(1) utf8_general_ci YES (NULL) select,insert,update,references 是否含食品添加剂 offmarket varchar(200) utf8_general_ci YES (NULL) select,insert,update,references 下架原因 applicant int(11) (NULL) YES (NULL) select,insert,update,references 提报人 applicationTime timestamp (NULL) NO 0000-00-00 00:00:00 select,insert,update,references 提报时间 auditor int(11) (NULL) YES (NULL) select,insert,update,references 审核人 auditTime timestamp (NULL) NO 0000-00-00 00:00:00 select,insert,update,references 审核时间 version int(11) (NULL) YES 0 select,insert,update,references 版本 isDelete tinyint(4) (NULL) NO 0 select,insert,update,references 是否删除:0=否,1= 是 subhead varchar(256) utf8_general_ci YES (NULL) select,insert,update,references 商品名称副标题 /*索引信息*/--------------Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment ------- ---------- ------------ ------------ ----------- --------- ----------- -------- ------ ------ ---------- ------- ---------------product 0 PRIMARY 1 productId A 637 (NULL) (NULL) BTREE product 1 useridIndex 1 userId A 318 (NULL) (NULL) YES BTREE product 1 brandIdIndex 1 brandId A 637 (NULL) (NULL) YES BTREE /*DDL 信息*/------------CREATE TABLE `product` ( `productId` int(11) NOT NULL AUTO_INCREMENT, `brandId` int(11) DEFAULT NULL COMMENT '产品所属的品牌', `userId` int(11) DEFAULT NULL COMMENT '卖家的Id', `name` varchar(256) DEFAULT NULL, `isShowInventory` tinyint(4) DEFAULT NULL COMMENT '前如页面是否显示库存:0=不显示,1=显示', `imageUrls` varchar(2048) DEFAULT NULL COMMENT '商品图片多个以逗号隔开,循序同前台一样', `description` longtext COMMENT '详细描述', `keyWord` varchar(256) DEFAULT NULL COMMENT '关键词,搜索用', `status` tinyint(4) DEFAULT NULL COMMENT '状态:1=草稿,2=待审核,3=审核通过,4=审核不通过', `remark` varchar(512) DEFAULT NULL COMMENT '审核不通过原因', `createTime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `updateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `sellType` tinyint(4) DEFAULT '1' COMMENT '售卖类型:1=普通,2=预售,3=抢购,4=团购,5=分期送', `preDeliveryTime` timestamp NULL DEFAULT NULL COMMENT '预发货时间', `recommendedReason` varchar(500) DEFAULT NULL COMMENT '推荐理由', `hits` int(11) DEFAULT '0' COMMENT '点击量', `productProp` varchar(500) DEFAULT NULL COMMENT '商品属性集合', `coverPicture` varchar(500) DEFAULT NULL COMMENT '封面图片', `aliasName` varchar(600) DEFAULT NULL COMMENT '商品前台显示名称', `rushQuantity` int(11) DEFAULT NULL COMMENT '抢购数量', `checkTime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '审核通过时间(发布时间)', `operator` int(11) DEFAULT '0' COMMENT '操作人', `operationTime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '操作时间', `manufacturer` varchar(100) DEFAULT '' COMMENT '生产商', `manufacturerAddress` varchar(100) DEFAULT '' COMMENT '生产地址', `manufactureLicence` varchar(50) DEFAULT '' COMMENT '生产许可证', `expiryDate` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '有效期', `productCode` varchar(50) DEFAULT NULL COMMENT '产品标准号', `barCode` varchar(50) DEFAULT NULL COMMENT '条码', `isOrganic` varchar(1) DEFAULT NULL COMMENT '是否有机', `isAdditives` varchar(1) DEFAULT NULL COMMENT '是否含食品添加剂', `offmarket` varchar(200) DEFAULT NULL COMMENT '下架原因', `applicant` int(11) DEFAULT NULL COMMENT '提报人', `applicationTime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '提报时间', `auditor` int(11) DEFAULT NULL COMMENT '审核人', `auditTime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '审核时间', `version` int(11) DEFAULT '0' COMMENT '版本', `isDelete` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否删除:0=否,1= 是', `subhead` varchar(256) DEFAULT NULL COMMENT '商品名称副标题', PRIMARY KEY (`productId`), KEY `useridIndex` (`userId`) USING BTREE, KEY `brandIdIndex` (`brandId`)) ENGINE=InnoDB AUTO_INCREMENT=100715 DEFAULT CHARSET=utf8 COMMENT='商品表'现在的问题是,查询出相同的userId出现的次数。
sql如下:
SELECT userid, COUNT(*) FROM product GROUP BY userid ORDER BY COUNT(*)
0 0
- 获取表中某一列的值出现的次数
- Postgresql 动态统计某一列的某一值出现的次数
- JDBC连接Mysql并统计指定关键词在某一列中出现的次数
- 获取某一表格的某一行某一列的值
- JavaScript获取table中某一列的值的方法
- JavaScript实现获取table中某一列的值
- EasyUI获取DataGrid中某一列的所有值
- EasyUI获取DataGrid中某一列的所有值
- PHP获取二维数组中某一列的值集合
- PHP获取二维数组中某一列的值集合
- ORACLE计算某个列中出现次数最多的值
- sql中查询同一列所有值出现的次数
- mysql统计字段中某一字符串出现的次数
- 字符串中某一子串出现的次数
- 在有序数组中,统计某一元素出现的次数
- 查找一个有序数组中某一数值出现的次数
- mysql统计字段中某一字符串出现的次数
- Ext获取某一列的值
- 找工作--笔试面试--准备9
- 第七周项目三之求某员工一周工资
- IOS backgroundfetch
- namedtuple
- c3p0配置详解<转贴>
- 获取表中某一列的值出现的次数
- 404页面 显示走失儿童信息
- 第八周项目一:分段函数求值
- 新一代站群软件
- restfus webservices获取数据的api方法
- 十个鲜为人知的 Linux 命令 - Part 4
- linux定时任务三
- 搜集到的linux高级命令
- 数据库三范式实例