Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Dec 2005
    Posts
    702
    Thanks
    0
    Thanked 0 Times in 0 Posts

    INNER JOIN to join two tables how I can use a filter

    When I use INNER JOIN to join two tables how I can use a filter: two fields one in the first and another in the second table to equal two vars [tell me an example] ?
    this is correct: SELECT table1.name, table1.address, table2.AID FROM table1 INNER JOIN table2 ON table1.name='" & Name & "' AND ON table2.AID='" & ID & "'"

  • #2
    New Coder
    Join Date
    Jul 2007
    Location
    North Carolina, US
    Posts
    32
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Is there a field that's the same in both tables?

  • #3
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,063
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Inner joins Must have a field that has a common value in both tables. They look like something this

    SELECT table1.name, table1.address, table2.AID FROM table1 INNER JOIN table2 ON table1.name=table2.name WHERE table1.name='" & Name & "' AND table2.AID='" & ID & "'"


    IN SQL SERVER or Oracle you can also use

    SELECT table1.name, table1.address, table2.AID FROM table1, table2
    WHERE table1.name = table2.name AND table1.name='" & Name & "' AND table2.AID='" & ID & "'"


  •  

    Posting Permissions

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