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 3349582
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:40:56+00:00 2026-05-18T01:40:56+00:00

I have an Actions table that records the actions taken by the users: ActionId,

  • 0

I have an Actions table that records the actions taken by the users:

ActionId, UserId

The Actions table holds the name and other details about the action, and Users table similarly holds the name and details about the users.

Now, in my application, I want to inform a user about the actions his friends have taken, something like:

“Person A, Person B, Person C have
taken this action.”

To do that, I am currently using GROUP_CONCAT() to concat the names of the people like:

SELECT GROUP_CONCAT(name) FROM Users
LEFT JOIN Actions ON Users.UserId = Actions.UserId
WHERE ActionId = '123'

However, I want to personalise this message in two ways.

  1. I want a “…, and ” before the last user, so it sounds more natural than a machine generated list.

  2. In cases where the user is also one of the people who have taken this action, I want to display a message like:

“Person A, Person B, Person C and you
have taken this action.”

What’s the most elegant way to achieve this? I am looking for a solution which is efficient enough for a large scale system.

  • 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-05-18T01:40:57+00:00Added an answer on May 18, 2026 at 1:40 am

    Really there’s no elegant way to do this sort of thing in SQL. You could of course write a cursor that’s checking for various conditions and building the string as you go along.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table in an Oracle database that contains actions performed by users
I have a table that records a sequence of actions with a field that
Hi all I have an appointments table that has among other fields a DATE
I have a table full of Actions. Each Action is done by a certain
I have a table and want to insert the current values of records that
I have a table Actions , schema blow: [Actions] ActionID Date Status <--Nullable, a
I have a query that basically combines tables of actions and selects from them
I have an SQL table written in MSSQL: create table [action] ( action_id bigint
I have a table where last column contains action buttons which opens another section
Lets say I have a table of statisctics: Page | Action | Time --------------------

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.