Results 1 to 2 of 2

Thread: Help zeroing in on data with query

  1. #1
    Join Date
    May 2008

    Help zeroing in on data with query

    Hey everyone,

    I'll start with my query since its pretty straight forward and will help me explain my problem.

    SELECT * FROM trailers_model_specs WHERE product_model_id='$foreach_value' && (product_spec_id IN (3, 15, 41))
    Basically, the script has a few product_model_id's and I need to find which product_model_ids have a record for each product_spec_id.

    Is there someway to do IN ALL, or what is the proper method? If the product_model_id was 3, and there was a record each for 3, 15, and 41 in the product_spec_id column with product_model_id=3, then I would include that product_model_number to display the model number.

    Thanks in advance for the help. I hope I explained it alright.

  2. #2
    Join Date
    Mar 2010
    If understand your question correctly, you have a list of product id's from somewhere and you want to check if each one of them exists in a record in a database table.

    If that is so, then maybe try something like this:

    foreach($modelNumberArray as $key => $value) {
          $query = 'select * from trailers_model_specs where product_spec_id = '.$value;
          // your code to run the query
          // if the number of rows returned is > 0 then print the $value
    Last edited by tirna; 03-21-2010 at 07:18 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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