Trouble with database query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mejmeyster
    New Member
    • Oct 2006
    • 6

    #1

    Trouble with database query

    Hi Everyone!

    I've been desperately trying to prepare a database query from Access to Excel. The problem is, when I ask MS Query to import data from more than one table, no data is importing, only the headings. The SQL is as follows:

    Code:
    SELECT Expense.Rent, Expense.Utilities, Assets.Cash, 
    FROM `C:\My Documents\Accounts`.Expense Expense, ‘C:\My Documents/Accounts’.Assets Assets 
    WHERE TransactionID = TransactionID
    Everything works fine when I import from only the Expense or Assets tables, but not from both. I only need the last line of the database, so is there some way to import just one line instead of every entry?

    Thanks so much for everyone's help!
    Last edited by NeoPa; Jan 27 '07, 12:38 AM. Reason: Tags for Layout
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    Don't know if this will work with Ms Query ...

    Code:
     
    SELECT Expense.Rent, Expense.Utilities, Assets.Cash, 
    FROM `C:\My Documents\Accounts`.Expense Expense As E INNER JOIN ‘C:\My Documents/Accounts’.Assets Assets As A
    ON E.TransactionID = A.TransactionID
    You could try designing the query in Access and using the query as the source instead.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32669

      #3
      You might want to change the SELECT line of Mary's improved code to :
      Code:
      SELECT E.Rent, E.Utilities, A.Cash
      Also look at the quotes used in your FROM clause. When shown in [ CODE ] tags they are not all the same (The Expense link uses incorrect quote characters).
      Your final code may look like :
      Code:
       
      SELECT E.Rent, E.Utilities, A.Cash
      FROM 'C:\My Documents\Accounts'.Expense As E
        INNER JOIN ‘C:\My Documents/Accounts’.Assets As A
        ON E.TransactionID = A.TransactionID

      Comment

      Working...