SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2005
    0 Post(s)
    0 Thread(s)

    grouping results in simple but big table

    Hi all

    I have a table like this

    |id | sku | Barcode |

    I have 55k+ records

    Some skus only have one barcode, some have up to six.

    I would like to display a table of all skus with the results of their barcodes after them eg

    |id | sku | Barcode1 | Barcode2 | Barcode 3 | Barcode 4 | Barcode 5 | Barcode 6 |
    1 a 12345
    2 b 123666 123654 123447
    3 c 98778

    I have tried a GROUP by statement but this does not seem to do what I am after.

    I am trying to display this on a page with PHP, but I feel I need to get the query right first. Or should I be looking to get PHP to do the work?


  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Toronto, Canada
    63 Post(s)
    3 Thread(s)
    if your database is mysql, you can do this quite easily with the GROUP_CONCAT aggregate function | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts