+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Forum Guru davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2007
    Posts
    1,879

    Modify this SQL to pick certain fields

    Hi

    I have the following SQL to define a Query as the inner join of two tables. How can I modify it to only include certain fields from each table?

    Code:
    CurrentDb.QueryDefs("qry_Test1").SQL = "SELECT * FROM tbl_QRM_Pipeline INNER JOIN tbl_UniFi_Pipeline1 ON tbl_QRM_Pipeline.Loan_Number = tbl_UniFi_Pipeline1.App_Number"
    For example, lets say I only want field "Dave1" from tbl_UniFi_Pipeline1 and field "Steve1" from tbl_QRM_Pipeline?

    Thanks!!
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  2. #2
    Registered User
    Join Date
    03-20-2008
    Location
    Buffalo, NY USA
    Posts
    43

    Re: Modify this SQL to pick certain fields

    Rather than "SELECT * FROM ..."
    phrase it as
    "SELECT tbl_UniFi_Pipeline1.Dave1, tbl_QRM_Pipeline.Steve1 FROM ..."

  3. #3
    Forum Guru davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2007
    Posts
    1,879

    Re: Modify this SQL to pick certain fields

    Ok, great. Rather than saying:
    "tbl_QRM_Pipeline INNER JOIN tbl_UniFi_Pipeline1"
    can I just put:
    "tbl_QRM_Pipeline, tbl_UniFi_Pipeline1"
    I'm seeing different options when I google, but I don't know if there is a difference in the results.

    Thanks
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  4. #4
    Registered User
    Join Date
    03-20-2008
    Location
    Buffalo, NY USA
    Posts
    43

    Re: Modify this SQL to pick certain fields

    I've never seen "tbl_QRM_Pipeline INNER JOIN tbl_UniFi_Pipeline1" replaced by "tbl_QRM_Pipeline, tbl_UniFi_Pipeline1" as a similar functioning join. INNER JOIN shows the intersections between the two tables - only the matches - related by Loan_Number and App_Number. The other "join" shows the Cartesian product between the two tables (table1 records * table2 records). It's really not a join - it's just two tables with no defined relationship between them. In 4 years of db development I think I've used it once.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0