locked
Complex Query Retrieval RRS feed

  • Question

  • User318405606 posted

    ASP Classic and MS SQL are not my main coding language so I have a question if anyone could please help me.

    I'm having to rework the code on a page and I have 4 separate SQL queries that if I could I would like to turn into one complex query.

    How can I query a database that some tables return multiple results for one item and then iterate through them.

    Tuesday, July 21, 2015 2:19 PM

Answers

  • User-1122936508 posted

    If the data is related, you can use INNER JOIN or OUTER JOIN in an SQL statement to join the tables together.

    If the data is unrelated, then you usually have to perform multiple queries - you could use a single stored procedure which returns multiple recordsets, or you use UNION or similar.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Tuesday, July 21, 2015 8:39 PM