發表文章

目前顯示的是 4月 17, 2019的文章

How create SQL pagination difficult join query with duplicate data?

圖片
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box; } 0 I have several tables in the database. Users, profiles and user roles. The relationship of profiles and users one to one. The relationship of roles and users many to many. To select all users, I send the following request: SELECT A.role_id, A.role_name, A.user_id,B.user_username, B.user_password, B.profile_color_text, B.profile_color_menu, B.profile_color_bg FROM (SELECT Roles.role_id, Roles.role_name, UserRoles.user_id FROM Roles INNER JOIN UserRoles ON Roles.role_id = UserRoles.role_id) AS A LEFT JOIN (SELECT Users.user_username, Users.user_password, Profiles.profile_color_text, Profiles.profile_color_menu