Join Query Syntax Error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ihere3010
    New Member
    • May 2014
    • 9

    Join Query Syntax Error

    the problem now is here

    Code:
    sqlstring = _
       " SELECT payed2.payroll, payed2.amount, " & _
          "payed2.type, payed2.page,payed1.datee, " & _
          "personal.email, personl.name, " & _
       " FROM  ((payed2 INNER JOIN payed1 " & _
          "ON payed2.page = payed1.page), " & _
          "INNER JOIN personal " & _
             "ON payed2.payroll = personal.payroll)) " & _
       " WHERE payed2.payroll = '" & mpayroll & _
          "' And payed2.Page = " & mpage & "" & _
       " ORDER BY payed2.payroll;"
    in join operation
    Last edited by zmbd; May 20 '14, 10:36 PM. Reason: [z{stepped the code, added a ";" as best practice}]
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1293

    #2
    ihere3010,
    Error 'data type mismatch' comes from comparing data items that are not the same type, typically comparing a numeric to a string, but it can also be comparing dates to non-dates etc... The compares can happen in a Where string, but also in a JOIN because JOINS are something like WHERE clauses in disguise. So if you try to join table Personal to table Payed2 on the field 'payroll' in both tables, and payroll is numeric in one table and not numeric in the other table, you'll get that type of error.

    So I'm going to guess that either
    payed2.page is not the same data type as payed1.page (payed2.page = payed1.page in JOIN)
    or
    payed2.payroll is not the same data type as personal.payrol l (payed2.payroll = personal.payrol l in Inner Join)
    or
    payed2.payroll is not a string (payed2.payroll = '" & mpayroll & "' in WHERE clause, the quotes indicate you're comparing strings)
    or
    payed2.Page = " & mpage & "" ... OOPS what's that, looks like an extra " at the end of your Where clause

    Looks like you were going for a numeric compare.
    payed2.Page = " & mpage looks like a numeric compare because there's no ' before you concatenate the mpage variable

    We don't know your table/column definitions so we can only guess what you meant. Pay close attention to column data types.

    Jim

    Comment

    • ihere3010
      New Member
      • May 2014
      • 9

      #3
      all fields joined in tables are matched but I still have problem in select syntax

      Comment

      • ihere3010
        New Member
        • May 2014
        • 9

        #4
        I think we are talk about the code as a whole I get it partially solved step by step now by your right recommendations and I need to complete it till end
        thanks million

        Comment

        • zmbd
          Recognized Expert Moderator Expert
          • Mar 2012
          • 5501

          #5
          This thread was split from a split thread here: http://bytes.com/topic/access/answer...ria-expression

          Please remember that each thread should be limited to one question/topic or very closely related followup questions.

          thnx

          Comment

          Working...