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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:25:47+00:00 2026-06-18T11:25:47+00:00

I have a table like this id | user_id | code | type |

  • 0

I have a table like this

id | user_id | code  | type | time
-----------------------------------
2    2         fdsa    r      1358300000
3    2         barf    r      1358311000
4    2         yack    r      1358311220
5    3         surf    r      1358311000
6    3         yooo    r      1358300000
7    4         poot    r      1358311220

I want to get the concatenated ‘code’ column for user 2 and user 3 for each matching time.

I want to receive a result set like this:

code     | time
-------------------------------
fdsayooo   1358300000
barfsurf   1358311000

Please note that there is no yackpoot code because the query was not looking for user 4.

  • 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-18T11:25:49+00:00Added an answer on June 18, 2026 at 11:25 am

    You can use GROUP_CONCAT function. Try this:

    SELECT GROUP_CONCAT(code SEPARATOR '') code, time 
    FROM tbl 
    WHERE user_id in (2, 3)
    GROUP BY time
    HAVING COUNT(time) = 2;
    

    SQL FIDDLE DEMO

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

Sidebar

Related Questions

I have a table like this: a | user_id ----------+------------- 0.1133 | 2312882332 4.3293
I have a table in my database like this: [id] [uniqueidentifier] NOT NULL, [user_id]
I have a couple of tables which look like this Table 1 user_id |
I have two tables like of this structure: content (content_id, content_type, user_id, time, comment_count)
I have a table in SQL Server which looks like this: ID Code Name
Suppose you have a table like this: id user score It's a dump of
I have a user table like this FIRSTNAME | LASTNAME | ID | --------------------------------
I have two MySQL tables something like this: tool_owners: tool_owners_id | user_id | ...
I have a table which stores test results like this: user | score |
I have a MySQL table which looks like this: ID OPTION 1 First 2

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.