Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8521781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:55:22+00:00 2026-06-11T06:55:22+00:00

MySQL is my weak point. I have the following MySQL query on a page

  • 0

MySQL is my weak point. I have the following MySQL query on a page of mine. The variables $this_groupMembers and $this_groupInvites are both predetermined strings in the form ‘1,2,3’ etc.:

SELECT
    username
FROM
    chat_users
WHERE
    ID IN($this_groupMembers) OR
    ID IN($this_groupInvites)

What I need to be able to do is to group the results so that I can access the existing members separately from the invited members. I.e. Create the variables $groupMembers_usernames and $groupInvites_usernames from the results of the MySQL query without having to dissect the results with PHP.

Is there a way to do this so that MySQL does all the work?

Thanks you,
Joe

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T06:55:23+00:00Added an answer on June 11, 2026 at 6:55 am

    You can use a UNION with constants to classify the returned rows:

    SELECT
        username, 'member'
    FROM
        chat_users
    WHERE
        ID IN($this_groupMembers)
    UNION
    SELECT
        username, 'invitee'
    FROM
        chat_users
    WHERE
        ID IN($this_groupInvites)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

MySQL is putting off the following error: You have an error in your SQL
MYSQL I want to filter "orders" according to their items within a form's checkboxes.
Mysql query question How to count as 1 if is 1,2 or 5 for
Mysql's environment is following: character_set_database=big5 And when I send a SQL which contains tranditional
I have a mysql table that includes the fields: Name - Year - Description
MySQL 4.0 doesn't have information_schema and 'show table status from db ' only gives
MySQL doesn't seem to have deffering constraints until the end of a transaction implemented
MySQL server version 5.0.45. Consider the following: ( SELECT CASE WHEN t.group_id = 12
MySQL tells me I have a wrong syntax, but I don't know where. Can
MySQL version 5.1.63-cll Using phpmyadmin to edit So i have this table ps_layered_price_index i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.