|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Inner join without keys
Hello,
I have two tables to join. I will use inner join as SELECT * FROM T1 X INNER JOIN T2 Y ON X.C1=Y.C1 WHERE X.C2>12; Problem is key of the first table is the combinatin of three fields of another. $left_table_id = $right_table_id1 . $right_table_id2 . $right_table_id3 I am not sore how to do this in query. It has to be something like that SELECT * FROM T1 X INNER JOIN T2 Y ON X.C1=Y.D1 . Y.D2 . Y.D3 WHERE X.C2>12; Any opinion? |
|
#2
|
|||
|
|||
|
Code:
ON X.C1 = Y.D1 || Y.D2 || Y.D3 will work if all columns are of character type, otherwise you have to cast to character varying before doing the concatenation. |
|
#3
|
|||
|
|||
|
Quote:
This seems very promising but I get that Code:
Warning: odbc_exec() [function.odbc-exec]: SQL error: [IBM][Client Access Express ODBC Driver (32-bit)][DB2/400 SQL]SQL0199 - Keyword ON not expected. Valid tokens: ( END SET CALL DROP FREE LOCK OPEN WITH ALTER BEGIN CLOSE FETCH., SQL state 37000 in SQLExecDirect in ... Can you give a hint about character varying? One field is varchar and others are int |
|
#4
|
|||
|
|||
|
It was my mistake. A typo broke the code.
It works, thanks |
![]() |
| Viewing: Dev Shed Forums > Databases > DB2 Development > Inner join without keys |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|