Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2002
    Posts
    1

    Arrow Unanswered: sql loop through

    Hi

    I have a recordset something like

    col1 | col2
    1 | <option>1</option>
    2 | <option>2</option>
    3 | <option>3</option>
    4 | <option>4</option>

    and I would really like a way to loop through in SQL to return a single record, not something that I have to then loop through in ASP.

    Help much appreciated.

    Joshua

  2. #2
    Join Date
    May 2003
    Location
    UK
    Posts
    220
    Howdy,

    Try this :

    SELECT col2 FROM table_name WHERE col1 = '2'

    2 is a value in the col1 column.

    This will select the value of col2 based on a specified value of col1

    Note: unless the database is case sensitivem, the commands are not case sensitive - its easier to understand if the case is altered to make certain stuff stand out.

    col1 | col2
    1 | <option>1</option>
    2 | <option>2</option>
    3 | <option>3</option>
    4 | <option>4</option>


    Cheers,

    SG

Posting Permissions

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