dbTalk Databases Forums  

Doing a join on a non-numeric column?

comp.databases.ibm-db2 comp.databases.ibm-db2


Discuss Doing a join on a non-numeric column? in the comp.databases.ibm-db2 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
DavidFilmer
 
Posts: n/a

Default Doing a join on a non-numeric column? - 03-10-2010 , 04:32 PM






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!

Reply With Quote
  #2  
Old   
Mark A
 
Posts: n/a

Default Re: Doing a join on a non-numeric column? - 03-10-2010 , 05:14 PM






"DavidFilmer" <usenet (AT) davidfilmer (DOT) com> wrote

Quote:
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.

Reply With Quote
  #3  
Old   
alandgri
 
Posts: n/a

Default Re: Doing a join on a non-numeric column? - 03-11-2010 , 08:52 AM



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... (AT) nowhere (DOT) com> wrote:
Quote:
"DavidFilmer" <use... (AT) davidfilmer (DOT) com> wrote in message

news:5ccd19e5-c611-4e14-bb83-0fab55ee8c2f (AT) k36g2000prb (DOT) 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.

Reply With Quote
  #4  
Old   
Arun Srini
 
Posts: n/a

Default Re: Doing a join on a non-numeric column? - 03-11-2010 , 08:53 AM



On Mar 11, 2:32 am, DavidFilmer <use... (AT) davidfilmer (DOT) com> wrote:
Quote:
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!
Where you partly drunk when you typed this or was it a typo when you
wrote the question? You have used OJB_id instead of OBJ_ID referring
to the table 'D'.

Reply With Quote
  #5  
Old   
Will Honea
 
Posts: n/a

Default Re: Doing a join on a non-numeric column? - 03-11-2010 , 03:42 PM



Arun Srini wrote:

Quote:
Where you partly drunk when you typed this or was it a typo when you
wrote the question? You have used OJB_id instead of OBJ_ID referring
to the table 'D'.
Now all who have never searched hours for a typo that some smart alec who
just dropped by spots instantly please raise you hands ;-)

--
Will Honea

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.