Ian James
Ian James

Reputation: 51

Inner join reference

I am having trouble referencing two columns when doing an inner join. I have tried the following combinations to no avail.

SELECT
*
FROM
adwords_final
INNER JOIN mk_kw ON adwords_final.Key = mk_kw.Key;

SELECT
*
FROM
adwords_final
INNER JOIN mk_kw ON "adwords_final.Key" = "mk_kw.Key";

Resulting in the following or something similar.

ERROR:  column adwords_final.key does not exist
LINE 5: INNER JOIN mk_kw ON adwords_final.Key = mk_kw.Key;
                        ^
HINT:  Perhaps you meant to reference the column "adwords_final.Key".
********** Error **********

ERROR: column adwords_final.key does not exist
SQL state: 42703
Hint: Perhaps you meant to reference the column "adwords_final.Key".
Character: 49

It appears to me that I am missing something more obvious. Do I need to reference even further up the latter or create a new query entirely?

Thanks

Columns within adwords final ;

Week    Keyword state   Keyword Campaign    Ad group    Status  Max. CPC    Impressions Interactions    Interaction Types   Interaction Rate    Avg. Cost   Cost    Clicks  Avg. position   Conversions Quality score   Ad relevance    Landing page experience Expected clickthrough rate  Qual. score (hist.) Ad relevance (hist.)    Landing page experience (hist.) Expected clickthrough rate (hist.)  Search Impr. share  Match type  First position CPC  Top of page CPC First page CPC  Impressions with average ctr    Impressions with above average ctr  Impressions with below average ctr  Impressions with below average lp exp   Impressions with average lp exp Impressions with above average lp exp   Impressions with below average Ad Rel   Impressions with  average ad rel    Impressions with above average ad rel   QSxIMP  Key

Columns within mk_kw

 Language   Network Main Keyword    Cluster Keyword 1   Match Type  Key

Upvotes: 0

Views: 79

Answers (1)

user330315
user330315

Reputation:

Every element of an identifier needs to be enclosed in double quotes. Not the complete identifier.

So you need to use:

"adwords_final"."Key" instead of "adwords_final.Key"

and

"mk_kw"."Key" instead of "mk_kw.Key"

Note that identifiers that are all lowercase do not need to be quoted. "mk_kw"."Key" is the same as mk_kw."Key"


For a complete description please see the chapter Identifiers and Key Words in the manual.

Upvotes: 1

Related Questions