#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    8
    Rep Power
    0
    I am running the following query:

    "SELECT name, price, productCode FROM products WHERE id IN '$ids'"

    Whenever I run this query, it only returns one row. In one of the tests, $ids contains every number form 142 to 158. But it only returns the product with id of 142. Is there something I am missing or is there an easier way to pull all the products with ids in $ids. $ids contains values that were pulled form another table in the database. Thanks for any help.

    -Josh
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    Josh,

    Is $ids in the format (142,143,144,145,146,147,148,etc)?

    The comparison must be a parenthesied <sp?>, comma delimited set for an IN clause
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    8
    Rep Power
    0
    Yes, it is a comma delimited list surrounded in parentheses. The query works other than I only get one record return instead of having all the ids in the list returned.

    -Josh
  6. #4
  7. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    Well, you need to remove the single quotes from around $ids, but I don't think that would cause the problem.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    8
    Rep Power
    0
    Thanks, Rod k.

    Removing the single quotes fixed it.

    -Josh

Similar Threads

  1. DreamWeaver MX and MySQL problem!!
    By genog in forum MySQL Help
    Replies: 3
    Last Post: February 12th, 2004, 07:57 AM
  2. MySQL query not getting array properly [PHP]
    By adz32 in forum MySQL Help
    Replies: 1
    Last Post: February 11th, 2004, 04:51 PM
  3. query problem
    By mjpr in forum .Net Development
    Replies: 1
    Last Post: February 9th, 2004, 05:43 AM
  4. MySQL lock tables problem: mysql hangs?
    By Cyclefreak in forum MySQL Help
    Replies: 0
    Last Post: February 6th, 2004, 08:24 AM
  5. MySQL Select query
    By MrTee1 in forum MySQL Help
    Replies: 0
    Last Post: January 30th, 2004, 12:16 PM

IMN logo majestic logo threadwatch logo seochat tools logo