> 데이터 베이스 > MySQL 튜토리얼 > 根据二度人脉推荐好友sql

根据二度人脉推荐好友sql

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
풀어 주다: 2016-06-07 15:59:31
원래의
1674명이 탐색했습니다.

friend表结构 DROP TABLE IF EXISTS FRIEND; create table friend( uid bigint not null comment '用户标识', friend_uid bigint not null comment '申请加为好友的用户标识', sys_create_date datetime not null comment '申请时间', sys_last_update datet

friend表结构

DROP TABLE IF EXISTS FRIEND;
create table friend(
uid bigint not null comment '用户标识',
friend_uid bigint not null comment '申请加为好友的用户标识',
sys_create_date datetime not null comment '申请时间',
sys_last_update datetime not null comment '更新时间',
state tinyint not null comment '好友状态 0 : 删除, 1:申请好友, 2 : 好友',
primary key(uid, friend_uid)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '好友表';

select friend_uid from

friend where state=2 and
uid in (select friend_uid from friend where uid=13 and state=2)

and friend_uid not in (select friend_uid from friend where uid=13 ) and friend_uid != 13 limit 6

uid为当前用户的ID,为id为13的用户查询二度人脉好友

관련 라벨:
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿