CREATE TABLE `user_phone` (
`userid` bigint(11) NOT NULL DEFAULT '0',
`phone` varchar(20) NOT NULL DEFAULT '',
`creation_date` datetime NOT NULL DEFAULT '2007-01-01 00:00:00',
PRIMARY KEY (`userid`,`phone`),
KEY `a` (`userid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1; CREATE TABLE `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=3159 DEFAULT CHARSET=latin1; 关系是user_phone是user的从表,userid 是外键
比如一个用户有多个手机号码
举个例子
id,name, userid, phone, creation_date1,
1 'haha', 1, '11111111111', '2007-01-01 00:00:00'
1, 'haha', 1, '13333333333', '2007-01-01 00:00:00'
1, 'haha', 1, '22222222222', '2007-01-01 00:00:00'
1, 'haha', 1, '33333333333', '2007-01-01 00:00:00'
2, 'hehe', 2, '12222222222', '2007-01-01 00:00:00'
如何输出我下面写的格式id,name, userid, phone, creation_date1,
1 'haha', 1, '11111111111', '2007-01-01 00:00:00'
1, '', 1, '13333333333', '2007-01-01 00:00:00'
1, '', 1, '22222222222', '2007-01-01 00:00:00'
1, '', 1, '33333333333', '2007-01-01 00:00:00'
2, 'hehe', 2, '12222222222', '2007-01-01 00:00:00'就是相同名字为空。谢谢各位了
`userid` bigint(11) NOT NULL DEFAULT '0',
`phone` varchar(20) NOT NULL DEFAULT '',
`creation_date` datetime NOT NULL DEFAULT '2007-01-01 00:00:00',
PRIMARY KEY (`userid`,`phone`),
KEY `a` (`userid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1; CREATE TABLE `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=3159 DEFAULT CHARSET=latin1; 关系是user_phone是user的从表,userid 是外键
比如一个用户有多个手机号码
举个例子
id,name, userid, phone, creation_date1,
1 'haha', 1, '11111111111', '2007-01-01 00:00:00'
1, 'haha', 1, '13333333333', '2007-01-01 00:00:00'
1, 'haha', 1, '22222222222', '2007-01-01 00:00:00'
1, 'haha', 1, '33333333333', '2007-01-01 00:00:00'
2, 'hehe', 2, '12222222222', '2007-01-01 00:00:00'
如何输出我下面写的格式id,name, userid, phone, creation_date1,
1 'haha', 1, '11111111111', '2007-01-01 00:00:00'
1, '', 1, '13333333333', '2007-01-01 00:00:00'
1, '', 1, '22222222222', '2007-01-01 00:00:00'
1, '', 1, '33333333333', '2007-01-01 00:00:00'
2, 'hehe', 2, '12222222222', '2007-01-01 00:00:00'就是相同名字为空。谢谢各位了
from user_phone A,user B
where A.id = B.userid
from user_phone a
inner jion b
on a.id=b.userid
这是我之前写的语句 输出
类似、
id,name, userid, phone, creation_date1,
1 'haha', 1, '11111111111', '2007-01-01 00:00:00'
1, 'haha', 1, '13333333333', '2007-01-01 00:00:00'
1, 'haha', 1, '22222222222', '2007-01-01 00:00:00'
1, 'haha', 1, '33333333333', '2007-01-01 00:00:00'
2, 'hehe', 2, '12222222222', '2007-01-01 00:00:00'
但是我希望能合并单元格 把重复的名字去掉。
谁会啊? 就是重复的 `haha` 都不要 就要第一个。
[征集]分组取最大N条记录方法征集,及散分....