/*
Navicat MySQL Data TransferSource Server : localhost
Source Server Version : 60002
Source Host : localhost:3306
Source Database : huadiTarget Server Type : MYSQL
Target Server Version : 60002
File Encoding : 65001Date: 2010-10-27 11:02:40
*/SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `ljz`
-- ----------------------------
DROP TABLE IF EXISTS `ljz`;
CREATE TABLE `ljz` (
`record_id` int(11) NOT NULL AUTO_INCREMENT,
`order_no` varchar(20) DEFAULT NULL,
`gd_no` varchar(50) DEFAULT NULL,
PRIMARY KEY (`record_id`),
KEY `idx_t_gd_az_zp_cust_myd` (`order_no`,`gd_no`) USING BTREE
) ENGINE=MyISAM AUTO_INCREMENT=1462 DEFAULT CHARSET=utf8;-- ----------------------------
-- Records of ljz
-- ----------------------------
INSERT INTO `ljz` VALUES ('3', '100519132835001', 'HD0760WX0001');
INSERT INTO `ljz` VALUES ('5', '100519132835002', 'HD0760WX0001');
INSERT INTO `ljz` VALUES ('8', '100519132835003', 'HD0760WX0002');
INSERT INTO `ljz` VALUES ('7', '100519132835004', 'HD0760WX0003');
mysql 实现查找出1个gd_no 对应有1个以上的order_no值 的gd_no
结果如下
gd_no
HD0760WX0001
Navicat MySQL Data TransferSource Server : localhost
Source Server Version : 60002
Source Host : localhost:3306
Source Database : huadiTarget Server Type : MYSQL
Target Server Version : 60002
File Encoding : 65001Date: 2010-10-27 11:02:40
*/SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `ljz`
-- ----------------------------
DROP TABLE IF EXISTS `ljz`;
CREATE TABLE `ljz` (
`record_id` int(11) NOT NULL AUTO_INCREMENT,
`order_no` varchar(20) DEFAULT NULL,
`gd_no` varchar(50) DEFAULT NULL,
PRIMARY KEY (`record_id`),
KEY `idx_t_gd_az_zp_cust_myd` (`order_no`,`gd_no`) USING BTREE
) ENGINE=MyISAM AUTO_INCREMENT=1462 DEFAULT CHARSET=utf8;-- ----------------------------
-- Records of ljz
-- ----------------------------
INSERT INTO `ljz` VALUES ('3', '100519132835001', 'HD0760WX0001');
INSERT INTO `ljz` VALUES ('5', '100519132835002', 'HD0760WX0001');
INSERT INTO `ljz` VALUES ('8', '100519132835003', 'HD0760WX0002');
INSERT INTO `ljz` VALUES ('7', '100519132835004', 'HD0760WX0003');
mysql 实现查找出1个gd_no 对应有1个以上的order_no值 的gd_no
结果如下
gd_no
HD0760WX0001
解决方案 »
- java 连接数据库mysql
- 求助,MYSQL难题,请高手支招
- mysqldump 如何导出 存储过程?
- mysql中根据列值大小查询排名的问题
- 如何在MySQL里面实现互斥的访问?如何保证select/update的原子操作?使用lock tables和unlock tables的效果如何?
- 请教:如何写一个sql ,create table 中联合字段做主键?
- mysql 百万级数据查询速度问题
- 求救!www.dk3.com的MySQL进不去!
- mysql默认字符集设置错了,已经创建的库 怎么修改为自己想要的字符集?
- mysql利用存储过程导出多级分类树形结构数据
- 求SQL语句!有点麻烦可能
- MYSQL版升星散分
select gd_no,count(*) from ljz group by gd_no having count(*) >1;
select gd_no,count(distinct(order_no)) from ljz group by gd_no having count(distinct(order_no)) >1;应该是这样。order_no也不可重复。