linking fields in queries

  • i'm trying to write a query in SQL, and I want to link fields with another query.

    what i'm wondering is; can i link fields between queries that i create on the fly (in other words, that don't have names)?

    i'd like to define a data set in the query window, and link a field from it to a field from another set defined in the same window.

    thanks

  • Sounds like a subquery...

    Something like

    SELECT <some fields>

    FROM <some tables> as st1

    JOIN (SELECT <some fields>

    FROM <some other tables>) AS st2 ON st2.<field> = st1.<field>

    Now, if you need the results of

    SELECT <some fields>

    FROM <some other tables>) AS st2

    for more than one query, put the results into a temporary table, and join to that.

    P

  • Sounds like a subquery...

    Something like

    SELECT <some fields>

    FROM <some tables> as st1

    JOIN (SELECT <some fields>

    FROM <some other tables>) AS st2 ON st2.<field> = st1.<field>

    Now, if you need the results of

    SELECT <some fields>

    FROM <some other tables>) AS st2

    for more than one query, put the results into a temporary table, and join to that.

    P

Viewing 3 posts - 1 through 2 (of 2 total)

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