View previous topic :: View next topic
|
Author |
Message |
rahuindo
New User
Joined: 09 Apr 2008 Posts: 83 Location: Chennai
|
|
|
|
How do i replace the 1st byte of a string 'A' of table XYZ with the 1st character of the string 'B' of table ABC within the same query?
For e.g. consider the following query:
Code: |
--Employee_Prefix_ID is a 1-byte field
--Employee_ID is a 10-bye Alphanumeric Field.
SELECT XYZ.EMPLOYEE_ID
ABC.EMPLOYEE_PREFIX_ID
FROM XYZ, ABC
WHERE XYZ.EMPLOYEE_ID = ABC.EMPLOYEE_ID
|
I want to replace the 1st byte of Employee_ID with the Employee_Prefix_ID. |
|
Back to top |
|
|
rahuindo
New User
Joined: 09 Apr 2008 Posts: 83 Location: Chennai
|
|
|
|
Hi,
I got the answer. We can write the following query.
Code: |
TRANSLATE(XYZ.EMPLOYEE_ID,ABC.EMPLOYEE_PREFIX_ID,
SUBSTR(XYZ.EMPLOYEE_ID,1,1)) AS "EMPLOYEE ID"
FROM XYZ, ABC
WHERE XYZ.EMPLOYEE_ID = ABC.EMPLOYEE_ID
|
|
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Perfect . . . . Thanks for coming back and posting us with the solution. |
|
Back to top |
|
|
|