Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2006

    Unanswered: Getting Multiple Rows from a Single Table

    Hello All -

    I'm really pulling my hair out over something that would appear to be very, very easy.

    I'm trying to get data from two columns (fld_04_hrs and fld_08_hrs) based upon "Kayak - Single" and "Kayak - Double" which are in column fld_type.

    So, what I need is the 4 hour and 8 hour data for BOTH Kayak Single and Kayak Double.

    I've written this query:

    $sql =
    "SELECT fld_04_hrs, fld_08_hrs
    FROM tbl_activities
    WHERE fld_type = 'Kayak - Single' OR fld_type = 'Kayak - Double'";

    But what I get are only the 4 and 8 hour values for Kayak Single.

    So then I tried this query:

    $sql =
    "SELECT fld_04_hrs, fld_08_hrs FROM
    WHERE fld_type IN('Kayak - Single','Kayak - Double')";

    Same result: 4 and 8 hour values for Kayak Single only.

    I CAN get the values I need by Select * and then doing a while loop to discard everything but Kayak Single and Kayak Double, but I guess that's about as inefficient as it gets.

    What am I doing wrong??? Can someone please help me get this right in one query statement?

    Thanks to all in advance!

  2. #2
    Join Date
    Feb 2004
    In front of the computer
    Provided Answers: 54
    I'd use
    SELECT fld_type, Count(1)
       FROM tbl_activities
       GROUP BY fld_type
       ORDER BY fld_type
    to find out what types are being used. My bet is that there isn't an exact match for the 'Kayak - Double' value. My first guess would be a non-printing character like an embedded or trailing space, but there could be a bazillion other "near miss" conditions.

    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Oct 2009
    221B Baker St.
    You might (only as a test) run the query looking for all of the rows where the fld_typ begins with Kayak ?

    If this does not identify the problem, look at those values in HEX.

Posting Permissions

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