View previous topic :: View next topic |
Author |
Message |
waves Beginner
Joined: 09 Nov 2006 Posts: 35 Topics: 12
|
Posted: Thu Oct 08, 2009 8:55 am Post subject: DB2 Query concat operator |
|
|
Hi,
I have got a db2 query where we are using CONCAT " in the query,
Code: |
SELECT * FROM Table1 A, Table2 B
WHERE A.ABC= B.ABC CONCAT ''
|
The column ABC is of same datatype.
When we ran the query with and without CONCAT ", we got the same output. There was no difference in the output.
Please help me in understanding the usage of CONCAT " in the where clause. Thanks in advance!! |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Thu Oct 08, 2009 10:44 am Post subject: |
|
|
waves,
You are not concatenating anything to the string. i.e you don't have any value between the quotes. So the query works same as if the concat is not there
Kolusu |
|
Back to top |
|
 |
CZerfas Intermediate
Joined: 31 Jan 2003 Posts: 211 Topics: 8
|
Posted: Fri Oct 09, 2009 6:23 am Post subject: |
|
|
Hello waves,
what your original query does is manipulating the access path to the data created by the DB2 optimizer.
Here a possible index access by DB2 is circumvented by transforming the equal predicate of the where clause (stage-1 processing by DB2, indexable) into a function call (stage-2 processing, not indexable). A similar manipulation for predicates on numeric values is adding 0 to the right side of the equation.
Sometimes these actions are advisable, when the structure of the contents of the column is different from the asumptions the DB2 optimizer is using (scewness of data, dependencies of one column from the values of another column in the same table, etc.)
This manipulation has nothing to do with the results of your query but only with the access path DB2 is using to get to the results.
regards
Christian |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Fri Oct 09, 2009 10:06 am Post subject: |
|
|
CZerfas,
Interesting way to manipulate access path . Thanks for the info
Kolusu |
|
Back to top |
|
 |
waves Beginner
Joined: 09 Nov 2006 Posts: 35 Topics: 12
|
Posted: Mon Oct 12, 2009 7:26 am Post subject: |
|
|
Thanks a Lot Kolusu and Christian!!!. That Really helps... |
|
Back to top |
|
 |
|
|