February 22nd, 2012, 02:24 PM
Match SQL syntax error (simple)
Can anyone help me with this?
I'm trying to do a simple select of matches across two tables.
Dealers with Portfolio
as shown below:
select * from [Customer Enrolled].[Location_Number_1] where [Customers Enrolled].[Location_Number_1] = [Dealers with Portfolio].[Location_Number]
I keep getting a syntax error.
What have I got wrong?
February 22nd, 2012, 04:28 PM
1. You cannot name your column in the from clause. So
is one mistake.
from [Customer Enrolled].[Location_Number_1]
2. You cannot use a table in where clause if that table is not refered to in from clause. To overcome this use inner join as follow:
and please please never use *, it is just a bad practice, always name the columns you want to return.
FROM [Customer Enrolled]
INNER JOIN [Dealers with Portfolio]
ON [Customers Enrolled].[Location_Number_1] = [Dealers with Portfolio].[Location_Number]
February 22nd, 2012, 04:29 PM
your FROM clause should have 2 tables mentioned in it
Originally Posted by SnapDaddy
right now it has none, just a column (which is invalid)
edit: no response for 2 hours, and then i get beaten out by 1 minute
February 22nd, 2012, 04:33 PM
Originally Posted by Mahdi Eftekhari