Results 1 to 4 of 4

Thread: Extra results from MYSQL query in PHP

  1. #1
    Join Date
    Jul 2007
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Extra results from MYSQL query in PHP

    what am i doing wrong here guys?

    $startrow=0;
    $limit=20;

    $qry = mysql_query("SELECT bodycare.*, haircare.* FROM bodycare, haircare WHERE bodycare.avail='true' AND haircare.avail='true' LIMIT $startrow, $limit")or
    die(mysql_error());

    it should return 6 results between bodycare and haircare. instead it returns 8, - 4 repeats of the first haircare product and 4 of the second haircare product.

    why? can you help me fix it?

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    try
    Code:
    SELECT DISTINCT bodycare.*  etc etc
    ... it sounds like you have just doubled up.

  3. #3
    Join Date
    Jul 2007
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    that doesn't remedy the situation. any other ideas guys?

  4. #4
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    WHERE bodycare.avail='true' AND haircare.avail='true'
    are you trying to pull in everything that is both both/haircare... are you if not.. possible use
    Code:
    WHERE bodycare.avail='true' OR haircare.avail='true'

    if thats not what you are trying to do... please give us more information... because without it, we will not be able to find why you are pulling in extra data that you dont want.

    the database will pull in everything that fits the "where" clause requirements

    a good start of information to give us is exactly what is being returned.

Bookmarks

Posting Permissions

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