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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:20:18+00:00 2026-06-01T15:20:18+00:00

i am just getting the result from a query like this user_id 108 183

  • 0

i am just getting the result from a query like this

user_id
108
183
172
129
158
178
117
104

and i want the result in this format

m1    m2   m3   m4   m5   m6   m7   m8
108  183  172  129  158  178  117   104

can anybody help me

  • 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-01T15:20:19+00:00Added an answer on June 1, 2026 at 3:20 pm

    You can use GROUP_CONCAT to get a similar resultset :

    SELECT GROUP_CONCAT( user_id ) FROM table GROUP BY user_id
    

    Otherwise if you want to create a new column for each row in the result set you can go with a CASE, but the values or the ranges of values must be hard coded :

    SELECT CASE WHEN user_id = 108 THEN user_id ELSE 0 END AS m1, CASE WHEN user_id = 183 THEN user_id ELSE 0 END AS m2, ...
    

    Or by ranges :

    SELECT CASE WHEN user_id > 100  AND user_id < 150 THEN GROUP_CONCAT(user_id) ELSE 0 END AS m1, CASE WHEN user_id > 150 AND user_id < 200 THEN GROUP_CONCAT(user_id) ELSE 0 END AS m2, ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just getting started with db2. Quick question about giving it SQL commands from a
I make two queries and I'd like to add rows from query 2 to
I have a LINQ query: var result = from mt in MessageTypes join mtfmt
Just getting started with C++ here. I am working on OSX with Eclipse CDT.
Just getting my feet wet with some Fluent NHibernate AutoMap conventions, and ran into
Just getting into SQL stored queries right now... anyway, here's my database schema (simplified
just getting myself familiar with jquery, please consider me as a noob for now.
Just getting started on NVelocity (v1.1.1) and it seems to be working just fine.
Just getting started building an app using the v6 of the facebook c# sdk
Just getting my head around WCF, so forgive me for the inelegant coding. The

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.