Multiple table sql statement?

Results 1 to 2 of 2

Thread: Multiple table sql statement?

  1. #1
    Join Date
    Dec 1969

    Default Multiple table sql statement?

    As of now Ive been using a db with one table to search through and get the Email field based on what information was filled out on a form. It is being based on state, county, and category and with one table I was using:<BR>strSQL = "SELECT DISTINCT EMail FROM Info WHERE Category=&#039;" & category &"&#039; AND State=&#039;" & state &"&#039; AND County=&#039;" & county &"&#039;"<BR><BR>But now the db is going to have multiple tables. I do believe I will only be dealing with two. One is BusCat(business category info) and Contact(has the email addys to the businesses. Fields will include UserID and Email). What I need to do, I figure, is based on the st, co, cat. selected on the form it will search through BusCat(the fields in BusCat will be ID, UserID, State, County, Category). I want to get the UserID from BusCat based on what st, co, cat match. So then it takes that UserID and matches it to the Contact table UserID field and pulls the info from the Email field from the Contact table. I hope this makes sense. Would this use JOIN or UNION to use both tables? Is it possible to search one table based on form information and then take the field from that table and match it to the other to get the emails? It sounds nutty Im sure. I wish I could describe or explain it better.<BR>Any help would be greatly appreciated. Or if there is already some discussions about this just point me in that direction.<BR><BR>Thanks.<BR>

  2. #2
    Join Date
    Dec 1969

    Default JOIN

    And if you haven&#039;t learned about JOINs, it&#039;s way past time to do so.<BR><BR>There are lots of good online resources, and there&#039;s even a nice free book in PDF format:<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