收集

重复记录只显示一条

/*
Navicat MySQL Data Transfer

Source Server         : localhost
Source Server Version : 50128
Source Host           : localhost:3306
Source Database       : test

Target Server Type    : MYSQL
Target Server Version : 50128
File Encoding         : 65001

Date: 2012-07-07 10:22:39
*/

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for `count`
-- ----------------------------
DROP TABLE IF EXISTS `count`;
CREATE TABLE `count` (
  `id` int(11) NOT NULL,
  `keyword` varchar(255) NOT NULL,
  `url` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- ----------------------------
-- Records of count
-- ----------------------------
INSERT INTO `count` VALUES ('1', 'a', 'aaa');
INSERT INTO `count` VALUES ('2', 'b', 'bbb');
INSERT INTO `count` VALUES ('3', 'c', 'ccc');
INSERT INTO `count` VALUES ('4', 'd', 'ddd');
INSERT INTO `count` VALUES ('5', 'f', 'aaa');
INSERT INTO `count` VALUES ('6', 'e', 'aaa');
INSERT INTO `count` VALUES ('7', 'j', 'bbb');


SELECT *, count(DISTINCT url) FROM count GROUP BY url;

SELECT DISTINCT url FROM count GROUP BY id;


------------------------------------------------------------------

MySQL中将字符串aaa批量替换为bbb的SQL语句   UPDATE 表名 SET 字段名 = REPLACE (字段名, 'aaa', 'bbb');


你可能感兴趣的:(收集)