Tricky SQL query!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Malc

    #1

    Tricky SQL query!

    I am writing an application which produces labels for an overnight
    Courier Company. In the mySQL database I have a field called 'NOP'
    which records the 'number of pieces' for each consignment.

    I have to produce one lable for each piece that is being shipped. The
    label production module currently accepts an SQL query and prints one
    label per returned row.

    Does anyone know if it is possible to write a select query which would
    produce a row based on the 'NOP' field? Imagine the following records

    NOP Destination
    --- -----------
    1 London
    1 Manchester
    2 Glasgow

    In this example, the Glasgow row would be repeated so that two labels
    would be printed.

    Any help appreciated.

    Malc.
  • Jeff North

    #2
    Re: Tricky SQL query!

    On 2 Jan 2004 15:40:25 -0800, in mailing.databas e.mysql
    mfowler@btinter net.com (Malc) wrote:
    [color=blue]
    >| I am writing an application which produces labels for an overnight
    >| Courier Company. In the mySQL database I have a field called 'NOP'
    >| which records the 'number of pieces' for each consignment.
    >|
    >| I have to produce one lable for each piece that is being shipped. The
    >| label production module currently accepts an SQL query and prints one
    >| label per returned row.
    >|
    >| Does anyone know if it is possible to write a select query which would
    >| produce a row based on the 'NOP' field? Imagine the following records
    >|
    >| NOP Destination
    >| --- -----------
    >| 1 London
    >| 1 Manchester
    >| 2 Glasgow
    >|
    >| In this example, the Glasgow row would be repeated so that two labels
    >| would be printed.
    >|
    >| Any help appreciated.
    >|
    >| Malc.[/color]

    You shouldn't be looking at the SQL statements to do this work but the
    routine(s) that print the actual label.

    Read data from table
    while NOT recordset.EOF
    for counter = 1 to recordset.NOP_v alue
    '--- print the label
    next
    get next record
    close recordset
    ---------------------------------------------------------------
    jnorth@yourpant sbigpond.net.au : Remove your pants to reply
    ---------------------------------------------------------------

    Comment

    • Jeff North

      #3
      Re: Tricky SQL query!

      On 2 Jan 2004 15:40:25 -0800, in mailing.databas e.mysql
      mfowler@btinter net.com (Malc) wrote:
      [color=blue]
      >| I am writing an application which produces labels for an overnight
      >| Courier Company. In the mySQL database I have a field called 'NOP'
      >| which records the 'number of pieces' for each consignment.
      >|
      >| I have to produce one lable for each piece that is being shipped. The
      >| label production module currently accepts an SQL query and prints one
      >| label per returned row.
      >|
      >| Does anyone know if it is possible to write a select query which would
      >| produce a row based on the 'NOP' field? Imagine the following records
      >|
      >| NOP Destination
      >| --- -----------
      >| 1 London
      >| 1 Manchester
      >| 2 Glasgow
      >|
      >| In this example, the Glasgow row would be repeated so that two labels
      >| would be printed.
      >|
      >| Any help appreciated.
      >|
      >| Malc.[/color]

      You shouldn't be looking at the SQL statements to do this work but the
      routine(s) that print the actual label.

      Read data from table
      while NOT recordset.EOF
      for counter = 1 to recordset.NOP_v alue
      '--- print the label
      next
      get next record
      close recordset
      ---------------------------------------------------------------
      jnorth@yourpant sbigpond.net.au : Remove your pants to reply
      ---------------------------------------------------------------

      Comment

      Working...