From: DavidFilmer on
Greetings. I'm trying to execute a DB2 command such as:

SELECT P.ITEM_NO,
D.FILE_NAME
FROM PRODDB2.PART P
LEFT JOIN PRODDB2.DATA D
ON P.OBJ_ID = D.OJB_ID

but I get: "D.OJB_ID" is not valid in the context where it is used.
SQLSTATE=42703

Ah, but OBJ_ID column is type CHAR(30). So I suppose I may need to
match with "like" instead of "=" So I change the last part:
ON P.OBJ_ID LIKE D.OJB_ID

Alas, that doesn't help:
An unexpected token "D" was found following "". Expected tokens
may include: ":". SQLSTATE=42601

What is the proper syntax for a join on a non-numeric column?

Thanks!
From: Mark A on
"DavidFilmer" <usenet(a)davidfilmer.com> wrote in message
news:5ccd19e5-c611-4e14-bb83-0fab55ee8c2f(a)k36g2000prb.googlegroups.com...
> Greetings. I'm trying to execute a DB2 command such as:
>
> SELECT P.ITEM_NO,
> D.FILE_NAME
> FROM PRODDB2.PART P
> LEFT JOIN PRODDB2.DATA D
> ON P.OBJ_ID = D.OJB_ID
>
> but I get: "D.OJB_ID" is not valid in the context where it is used.
> SQLSTATE=42703
>
> Ah, but OBJ_ID column is type CHAR(30). So I suppose I may need to
> match with "like" instead of "=" So I change the last part:
> ON P.OBJ_ID LIKE D.OJB_ID
>
> Alas, that doesn't help:
> An unexpected token "D" was found following "". Expected tokens
> may include: ":". SQLSTATE=42601
>
> What is the proper syntax for a join on a non-numeric column?
>
> Thanks!

No difference for non-numeric columns. Please post DDL for the tables and
indicate the schema names of the tables.


From: alandgri on
Is it intended or is it a typo that you have two different field names
there, OJB and OBJ?

On Mar 10, 4:14 pm, "Mark A" <no...(a)nowhere.com> wrote:
> "DavidFilmer" <use...(a)davidfilmer.com> wrote in message
>
> news:5ccd19e5-c611-4e14-bb83-0fab55ee8c2f(a)k36g2000prb.googlegroups.com...
>
>
>
>
>
> > Greetings.  I'm trying to execute a DB2 command such as:
>
> >   SELECT         P.ITEM_NO,
> >                  D.FILE_NAME
> >   FROM              PRODDB2.PART    P
> >   LEFT JOIN         PRODDB2.DATA    D
> >   ON                P.OBJ_ID = D.OJB_ID
>
> > but I get: "D.OJB_ID" is not valid in the context where it is used.
> > SQLSTATE=42703
>
> > Ah, but OBJ_ID column is type CHAR(30).  So I suppose I may need to
> > match with "like" instead of "="  So I change the last part:
> >   ON                P.OBJ_ID LIKE D.OJB_ID
>
> > Alas, that doesn't help:
> >   An unexpected token "D" was found following "".  Expected tokens
> > may include:  ":".  SQLSTATE=42601
>
> > What is the proper syntax for a join on a non-numeric column?
>
> > Thanks!
>
> No difference for non-numeric columns. Please post DDL for the tables and
> indicate the schema names of the tables.