select t1.self_user_id , t1.like_user_id from sys_activity_user_like t1 inner join sys_activity_user_like t2 on t1.self_user_id = t2.like_user_id and t2.self_user_id = t1.like_user_id where t1.self_user_id = 1
sql语句如上所示:从sys_activity_user_like这个表中内关联即可,表结构如下所示:
CREATE TABLE `sys_activity_user_like` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', `self_user_id` bigint(20) DEFAULT NULL COMMENT '用户ID', `like_user_id` bigint(20) DEFAULT NULL COMMENT '心动用户ID', `activity_id` bigint(20) DEFAULT NULL COMMENT '活动ID', `status` tinyint(4) DEFAULT '1' COMMENT '状态(0.删除;1.正常)', `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='用户参加活动心动对方表'
其实就是从关系表中,查询出相互有关系的数据。
标签:COMMENT,like,DEFAULT,userid,喜欢,user,MySQL,NULL,id From: https://www.cnblogs.com/jelly12345/p/17367848.html