combining 2 recordsets?

Results 1 to 3 of 3

Thread: combining 2 recordsets?

  1. #1
    Join Date
    Dec 1969

    Default combining 2 recordsets?

    is there a way to grab 2 recordsets and combine them into one? i have to do 2 b/c of the way my sql statements have to be, but i&#039;m grabbing the same columns in both queries. i&#039;d like to combine them into one afterwards... is this possible?<BR>thanks!!!

  2. #2
    Join Date
    Dec 1969
    Los Angeles, CA

    Default Use SQL....use UNION <eop>


  3. #3
    Join Date
    Dec 1969

    Default UNION

    SELECT fld1, fld2, fld3 FROM table1 WHERE something=whatever<BR>UNION<BR>SELECT fldx, fldy, fldz FROM table2 WHERE anything &#062; tiny<BR>ORDER BY fld1, fld3<BR><BR>RULES:<BR><BR>The two SELECTs must get the same number of fields. If one SELECT would return too few fields, pad it out with NULL or other dummy values.<BR><BR>The types of the fields in the second (or third or fourth...) SELECT must correspond, in sequential order, to the types of the fields in the first SELECT. [Some latitude is usuallly allowed here: If the first SELECT returns a DOUBLE for field 3, then the second SELECT can usually return an int for that field. Or a VarChar field can be mixed with Char fields. Etc. This all varies by DB.]<BR><BR>The ORDER BY clause applies to the entire UNION. You can either use the field names from the first SELECT or use ordinal positions (e.g., ORDER BY 2,1).<BR><BR>Duplicate records are automatically eliminated unless you use UNION ALL.<BR><BR>See the docs on UNION for your own DB for more info.<BR><BR>

Posting Permissions

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