Best query strategy

  • I am faced with the need to query the price of parts from a 3 table join.  The problem is the number of parts that need to be queried at one time; 10 to 100 parts.  That would make for a very messy WHERE clause.  I am wonder if there is a better strategy?

    If it matters, I am using VB.NET.

    Thanks

    --Rob

  • Why not stick the part numbers to be queried in a temp table and make it a 4 table join?


    And then again, I might be wrong ...
    David Webb

  • OK.  That's one I didn't think of.  Thanks for the idea!

  • Is the SQL in a stored procedure ?

    There are some alternatives:

    1. Pass the part numbers as a single string as either fixed positions or delimited. See http://www.sommarskog.se/arrays-in-sql.html for how to convert the string into a table.

    2 Pass the part numbers as XML and then convert to a table

    With either solution, you would finaly have a temporary table with one row for each part number that you would join to the existing SQL.

    SQL = Scarcely Qualifies as a Language

  • Why not make a 4th table that would keep the kits, and then do the sum based on a kit?

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply