0

Can anyone help me what is the problem with this,as I am getting an error as An error occurred while checking the query syntax. Errors: Ambiguous column name 'RMNumber'.


SELECT 
[RMNumber] AS 'RMNumber'
,[Name] AS 'Name'
,[City] AS 'City'
FROM [MBtest1] A
INNER JOIN [MBtest2] B ON A.[RMNumber] = B.[RMNumber]

2 Answers 2

3

The query is confused about which fields it should return because of the common names in the data extensions. It is bet practice to prepend the fields you'd like to return with the DE alias.

Also, since you are not actually renaming the column headers it is not necessary to alias them with "as" which has been done in the original question.

Please try the below:

SELECT 
    A.[RMNumber],
    B.[Name],
    B.[City] 
FROM
    [MBtest1] A 
INNER JOIN 
    [MBtest2] B 
ON 
    A.[RMNumber] = B.[RMNumber]
1
  • Welcome to SFSE charliefay. Thank you for contributing with your first answer, however I fail to see how this adds to the answer I have already provided below, as it gives more or less exactly same advice? Commented Nov 8, 2019 at 14:41
2

As RMNumber is a field in both DEs, the query doesn’t know which one to return. And yes, even though you join in the field, and they are exactly the same, you still need prepend it with a DE name or alias, as below:

SELECT A.[RMNumber] AS 'RMNumber' ,
[Name] AS 'Name' ,[City] AS 'City' 
FROM [MBtest1] A 
INNER JOIN [MBtest2] B 
ON A.[RMNumber] = B.[RMNumber]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .