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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:19:35+00:00 2026-05-13T06:19:35+00:00

i have this code SELECT DISTINCT idx_campus_bookinfo,c.userid as Buyer,bookname,book_explain,writedate FROM campus_bookinfo cb LEFT JOIN

  • 0

i have this code

SELECT DISTINCT idx_campus_bookinfo,c.userid as Buyer,bookname,book_explain,writedate
FROM campus_bookinfo cb 
LEFT JOIN user_books ub ON idx_campus_bookinfo = id_product
LEFT JOIN customer c ON ub.id_customer = c.id_customer
where cb.idx_campus = 1 and cb.idxuser = 29 ORDER BY writedate DESC

which give an output of

Click to View output

My Question is how can i make the buyer column to be delimited by comma which has the same book.

  • 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-13T06:19:35+00:00Added an answer on May 13, 2026 at 6:19 am

    Use the GROUP_CONCAT function, but it means having to replace DISTINCT with a GROUP BY:

        SELECT idx_campus_bookinfo,
               GROUP_CONCAT(c.userid SEPARATOR ',') as Buyer,
               bookname,
               book_explain,
               writedate
          FROM campus_bookinfo cb 
    LEFT JOIN user_books ub ON idx_campus_bookinfo = id_product
    LEFT JOIN customer c ON ub.id_customer = c.id_customer
        WHERE cb.idx_campus = 1 
          AND cb.idxuser = 29 
     GROUP BY idx_campus_bookinfo, bookname, book_explain, writedate
     ORDER BY writedate DESC
    

    a followup question, can i sort the userid?

    Yes, you can:

        SELECT idx_campus_bookinfo,
               GROUP_CONCAT(c.userid ORDER BY c.userid ASC SEPARATOR ',') as Buyer,
               bookname,
               book_explain,
               writedate
          FROM campus_bookinfo cb 
    LEFT JOIN user_books ub ON idx_campus_bookinfo = id_product
    LEFT JOIN customer c ON ub.id_customer = c.id_customer
        WHERE cb.idx_campus = 1 
          AND cb.idxuser = 29 
     GROUP BY idx_campus_bookinfo, bookname, book_explain, writedate
     ORDER BY writedate DESC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: cursor.execute( ''' SELECT id,DISTINCT tag FROM userurltag ''') tags =
i have this code for fill combo-box SQL = SELECT DISTINCT Name,Num FROM MyTbl
I have this PHP code: $result = mysql_query(SELECT distinct om_quote_no from `porders` order by
I have this code in Access: SELECT DISTINCT p.course, p.date FROM Student s, Participation
I have this code here printf '$request1 = select * from whatever where this
I have this code: con.Open(); cmd = new MySqlCommand(String.Format(SELECT concat(name,'|',lastname) FROM {0} WHERE ID=
I have this code which permits me to get some ids $sql_id_att=SELECT DISTINCT att_id
I have this piece of code: Tipo_Id = mysql_real_escape_string($_REQUEST[tipo]); $Sql = SELECT DISTINCT(tabveiculos.Marca_Id), tabmarcas.Marca_Nome
I have this code for a select box which is being displayed by the
i have this code right here: <select name=group> <option value=>Choose a group....</option> <?php foreach($groups

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.