我有这张table:
CREATE TABLE one (
id bigint(11) primary key,
email varchar(100),
refer_link varchar(8),
referrer varchar (8)
);
当用户提交表单时,他们会得到一个唯一的refer链接(refer\u link)。当另一个用户提交表单时,在他的referer列中插入了该链接。
因此,在示例中,我将有一个表:
id email refer_link referrer
---------------------------------------------------------
1 jerry@jerry.com ref11111
2 elaine@elaine.com ref22222 ref11111
3 george@george.com ref33333 ref22222
4 kramer@kramer.com ref44444 ref11111
5 cosmo@cosmo.com ref55555 ref44444
如何创建此视图?
email refer_email refer_count
--------------------------------------------------------
jerry@jerry.com 2
elaine@elaine.com jerry@jerry.com 1
george@george.com elaine@elaine.com 0
kramer@kramer.com jerry@jerry.com 1
cosmo@cosmo.com kramer@kramer.com 0
非常感谢你的帮助!
2条答案
按热度按时间3gtaxfhh1#
尝试下面的子查询,
xdnvmnnf2#