• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 290
  • Last Modified:

mysql syntax error

I'm working along side a book. I'm certain I copied this command out of the book verbatim. I'm getting an error message.

SELECT columns
FROM table1 INNER JOIN table2
 ON condition(s) for data to be related;


MySQL said:

#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 'condition(s) for data to be related
LIMIT 0, 30' at line 3

Any idea on what's incorrect?
Thanks
0
burnedfaceless
Asked:
burnedfaceless
  • 2
1 Solution
 
Kim WalkerWeb Programmer/TechnicianCommented:
You are supposed to supply the "condition(s) for data to be related." For example, if both tables have a field named column1 with identical information:

SELECT columns
FROM table1 INNER JOIN table2
ON column1

Open in new window

0
 
burnedfacelessAuthor Commented:
Thank you. My n00bness is showing.
0
 
Kim WalkerWeb Programmer/TechnicianCommented:
Disregard my last comment. There's more that you have to supply and I confused ON with USING. You also have to supply the columns to be selected. For example:

SELECT table1.column1, table2.column2
FROM table1 INNER JOIN table2
ON table1.column1 = table2.column1

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now