Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. MySQL
  4. not sure the best approach to this problem....

not sure the best approach to this problem....

Scheduled Pinned Locked Moved MySQL
tutorialdatabasesaleshelpquestion
2 Posts 1 Posters 14 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cjoki
    wrote on last edited by
    #1

    OK, I have 2 tables one has product information grouped by a sales order id. another table has a list of serial numbers related to the items pulled out of stock to fill that order. What I want to do is run a query/subquery to provide a single resultset that includes the info for the products on a sales order and a comma seperated list of serial numbers of the producted that was pulled. for example i would like my result set to look something like this.... result ==========

    order_id prod_id qty sn unit_price
    100123 12345 2 abcd123,abcd124 2.99
    100123 12346 1 bbcd123 1.99

    any suggestion on how to do this on one query...? Thanks! Chris

    C 1 Reply Last reply
    0
    • C cjoki

      OK, I have 2 tables one has product information grouped by a sales order id. another table has a list of serial numbers related to the items pulled out of stock to fill that order. What I want to do is run a query/subquery to provide a single resultset that includes the info for the products on a sales order and a comma seperated list of serial numbers of the producted that was pulled. for example i would like my result set to look something like this.... result ==========

      order_id prod_id qty sn unit_price
      100123 12345 2 abcd123,abcd124 2.99
      100123 12346 1 bbcd123 1.99

      any suggestion on how to do this on one query...? Thanks! Chris

      C Offline
      C Offline
      cjoki
      wrote on last edited by
      #2

      nm, I figured it out the query I used is.... SELECT t1.ProductID, t1.ListNum, t1.Quantity AS Qty, t1.UnitPrice, (SELECT GROUP_CONCAT( sn SEPARATOR ', ' ) FROM sn_table AS t2 WHERE t1.listnum = t2.listnum GROUP BY listnum ) AS SN FROM ProductList AS t1 WHERE t1.OrderID = 'ORD000023' works like a charm!

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups