I am trying to get a person's groups baseed on whether they are a member, invited, host, admin, mod or requested to join on MYSQL.
I have tried the query below:
var qSelect = "SELECT DISTINCT g.id, g.title, media.media_link, g_host.member_type, g_admins.member_type, g_mods.member_type, g_members.member_type, g_invites.member_type, g_requests.member_type FROM Groups g, Media media, Group_Hosts g_host, Group_Admins g_admins, Group_Moderators g_mods, Group_Members g_members, Group_Invites g_invites, Group_Requests g_requests" +
"WHERE media.group_id = g.id AND " +
"((g_host.user_id = ? AND g_host.group_id = g.id) OR " +
"((g_admins.user_id = ? AND g_admins.group_id = g.id) OR " +
"((g_mods.user_id = ? AND g_mods.group_id = g.id) OR " +
"((g_members.user_id = ? AND g_members.group_id = g.id) OR " +
"((g_invites.user_id = ? AND g_invites.group_id = g.id) OR " +
"((g_requests.user_id = ? AND g_requests.group_id = g.id))" +
"ORDER BY g.id DESC";
But get the following error:
get my groups error: Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' Media media, Group_Hosts g_host, Group_Admins g_admins, Group_Moderators g_mods' at line 1
I am using NodeJs.
Appreciate any help or direction.
Also, if the design of the query is going to be slow or bad in performance, please let me know. I am expecting there to be over 100k rows in each of these tables, but each user should have only about 10 in each.