Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2017
    Posts
    1

    Unanswered: Join and Not Equal to results

    Hello… I am a newbie to MySQL and I am in need of joining two tables which are actually called Orders 1 and Orders 2. I am looking to join on NAME (which is the order number), LineItemName, and LineItemQuantity. I specifically need to show where LineItemQuantity is not equal. Here is what I have, but I get this error. “#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't2. FROM Orders 1 t1 INNER JOIN Orders 2 t2 ON t2.OrderNumber = t1.OrderNumber A' at line 1”

    The #1064 is an order number and I’m not sure if it is a format issue, or just bad code. 

    Please be detailed about HOW to do it and correcting me.

    SELECT t1.,t2.
    FROM Orders 1 t1
    INNER JOIN Orders 2 t2 ON
    t2.OrderNumber = t1.OrderNumber
    AND t2.LineItemName = t1.LineItemName
    AND t2.LineItemQuantity <> t1.LineItemQuantity

    I need to see just these three fields on the results. How do I go about that?

    Thanks in advance!

    Brian

  2. #2
    Join Date
    Sep 2002
    Location
    Montreal, Canada
    Posts
    228
    Provided Answers: 1
    Read the error message and just look a little bit more closely...

    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't2. FROM Orders 1 t1 INNER JOIN Orders 2 t2 ON t2.OrderNumber = t1.OrderNumber A' at line 1

    The very important word & hint is NEAR...

Posting Permissions

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