multiple tables/same objRS question

Results 1 to 2 of 2

Thread: multiple tables/same objRS question

  1. #1
    Join Date
    Dec 1969

    Default multiple tables/same objRS question

    ok, if I have a recordset that retreives data from two different tables. Is there anything special that I need to do in the &#039select&#039 sql statement to specify which table each column is from , or do i just list them as i normally would. Please tell me if you dont understand the question.<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: multiple tables/same objRS question

    *IF* each field name in each table is unique in the set of combined field names, you need do nothing. SELECT * will get all the fields, and RS("name") will get the expected field.<BR><BR>But if you use the same field name in each table (a pretty common thing to do), then you will probably need to explicitly name the SELECTed fields. And if you really *need* the values from *both* fields of the same name, then you will need to use AS to "rename" one of them.<BR><BR>So:<BR><BR>SELECT AS t1Name, AS t2Name,, FROM users AS t1, employees AS t2<BR><BR>or whatever.<BR><BR>Note that it can never hurt to explicitly call out field names, as if nothing else you will *know* that you are getting the fields in the order you want them, which can be important if you will use RecordSet.GetRows or RecordsSet.GetString or, perhaps, if you have a MEMO field (that must, of course, be the last field in the list).<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