我在 MySQL 中有这个查询
SELECT
@rownum:=@rownum+1 AS rownum,
notifications_posts.from_user AS source,
notifications_posts.on_post_id AS destination,
notifications_posts.in_group_id,
groups.group_name AS group_name,
notifications_posts.on_post_id AS other_record_id,
user_info.first_name,
user_info.last_name,
user_info.user_id,
notifications_posts.date,
posts.title AS 'title',
user_rights.right AS 'right',
'article' AS notification_type
FROM notifications_posts
INNER
JOIN user_info
ON notifications_posts.from_user = user_info.user_id
INNER
JOIN posts
ON posts.id = notifications_posts.on_post_id
INNER
JOIN groups
ON groups.group_id = notifications_posts.in_group_id
INNER
JOIN user_rights
ON user_rights.group_id = notifications_posts.in_group_id AND user_rights.user_id = user_info.user_id
我明白了
为什么我NULL
得到rownum
?
其次,我需要按该 ID 对记录进行分组
GROUP BY rownum;
谁能帮我?