sql queries - 2 tables

Results 1 to 2 of 2

Thread: sql queries - 2 tables

  1. #1
    Join Date
    Dec 1969

    Default sql queries - 2 tables

    Hi I have 2 recordsets - 1 called "vehicles" that has a field called "user_ID" (which isn´t the autonumber ID) and another recordset called "car_dealer" which autonumber is called "user_ID" and another field i will show called "dealer" .<BR><BR>"user_ID" form "RSet vehicles" and "user_ID" from "RSet car_dealer" have a connection in the relationship editor (ACCESS)<BR><BR>I want the following. Show all vehicles from 1 recordset and insert 1 recordset field from "car dealers" into the same table where the user ids are the same. Any clues ??

  2. #2
    Join Date
    Dec 1969

    Default It's called a JOIN...

    ...and its the most basic of SQL operations.<BR><BR>I have to ask: WHY did you name that field "user_ID" instead of "dealerID"????????????<BR><BR>Oh, well...<BR><BR>There are two basic ways to do a JOIN: <BR><BR>(1) An EXPLICIT join.<BR><BR>SELECT &#060;put list of fields here&#062;<BR>FROM vehicles INNER JOIN car_dealer<BR>ON ( vehicles.user_id = car_dealer.user_id )<BR>WHERE &#060;put your conditions here&#062;<BR>ORDER BY &#060;field(s)&#062;<BR><BR>I you had used the Access query designer to design this query for you (it&#039;s truly trivial--you must click on "new query", choose the two tables from a list, and then choose the fields you want SELECTed), this is the kind of query it would generate.<BR><BR>*********<BR><BR>(2) An IMPLICIT join<BR><BR>SELECT &#060;put list of fields here&#062;<BR>FROM vehicles, car_dealer<BR>WHERE ( vehicles.user_id = car_dealer.user_id )<BR>AND &#060;put your other conditions here&#062;<BR>ORDER BY &#060;field(s)&#062;<BR><BR>This is the older form of join, but it is still supported by all major relational database engines that I know of.<BR><BR>*******<BR><BR>Time to find a SQL tutorial. There are a few online, if you aren&#039;t ready to buy a book.<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