数据库结构如下:
传入 productId
返回 蓝色部份 不重复的值附mysql脚本:SET FOREIGN_KEY_CHECKS=0;-- ----------------------------
-- Table structure for `goods`
-- ----------------------------
DROP TABLE IF EXISTS `goods`;
CREATE TABLE `goods` (
  `id` varchar(255) NOT NULL,
  `productId` varchar(255) NOT NULL ,
  `pricingRule` tinyint(4) NOT NULL ,
  `stockNum` int(11) NOT NULL ,
  `points` decimal(10,3) NOT NULL DEFAULT '0.000' ,
  `price` decimal(10,2) DEFAULT NULL ,
  `weight` decimal(10,3) DEFAULT NULL ,
  `lenght` int(11) DEFAULT NULL ,
  `diameter` int(11) DEFAULT NULL ,
  `type` varchar(255) DEFAULT NULL ,
  `sex` varchar(255) DEFAULT NULL ,
  `style` varchar(255) DEFAULT NULL ,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;-- ----------------------------
-- Records of goods
-- ----------------------------
INSERT INTO `goods` VALUES ('00', '1', '0', '0', '0.000', '0.00', '0.000', '0', null, null, null, null);
INSERT INTO `goods` VALUES ('00s', '0', '0', '0', '0.000', '0.00', '0.000', '0', null, null, null, null);
INSERT INTO `goods` VALUES ('g01', '1', '0', '10', '0.010', '16.00', null, '23', '4', null, '1', null);
INSERT INTO `goods` VALUES ('g02', '1', '0', '12', '0.010', '15.00', '0.100', null, '4', null, null, null);
INSERT INTO `goods` VALUES ('sdf', '2', '0', '0', '0.000', '0.00', '0.000', '0', '0', null, '0', null);
INSERT INTO `goods` VALUES ('sds', '1', '0', '0', '0.000', null, null, null, null, null, '2', null);
INSERT INTO `goods` VALUES ('wec', '1', '1', '1', '1.000', '1.00', '1.000', '1', '1', '1', null, null);

解决方案 »

  1.   

    由于楼主没有贴出结果是什么样。 从中文语言描述来看,以下语句应该是满足 "返回 蓝色部份 不重复的值" 要求的。select distinct `weight` ,  `lenght` ,  `diameter`,  `type`,  `sex` ,  `style`
    from goods
    where productId=??
      

  2.   


    传入 productId
    返回 蓝色部份 不重复的值 是什么意思? 有没有具体,比如传入xx值,出来什么结果