Advertisement:

Author Topic: SQL Query Question  (Read 183 times)

Offline MisterVertigo

  • Semi-Newbie
  • *
  • Posts: 10
SQL Query Question
« on: October 22, 2019, 10:29:54 AM »
Hello all! I'm hoping this is the right place for this. If not, please let me know and I can re-post elsewhere.

I'm trying to run a MySQL query against my SMF database to pull some data that I can then open in a spreadsheet. I'm trying to pull user data (name, e-mail, joindate, usergroup, and membergroups).

I've got the query to get the data I need from the users table, and I know how to do a join to get the Primary Membergroup name. However, when it comes to the Additional Membergroups, users can be a member of several and they are stored as id's separated by a comma in the user table. How can I pull the name of each group instead of just the id for this field?

Thank you in advance for your time!

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 73,189
Re: SQL Query Question
« Reply #1 on: October 22, 2019, 10:31:59 AM »
You basically can’t in raw SQL.
No good deed goes unpunished
All helpful urges should be circumvented

Offline MisterVertigo

  • Semi-Newbie
  • *
  • Posts: 10
Re: SQL Query Question
« Reply #2 on: October 22, 2019, 10:35:08 AM »
I was kind of afraid of that. If I was going to display on a web page with PHP I know I could do it no problem, but wasn't sure if I could in just SQL. Thank you though!