View previous topic :: View next topic
|
Author |
Message |
vkrajuch
New User
Joined: 22 Jun 2005 Posts: 5 Location: hyderabad
|
|
|
|
Hi Friends,
check out this funny query see how DB2 reacts
first try a normal one
--> Select field-a, field-b from table
check the result
Now try this query
--> Select field-a field-b from table
Note that there is no comma between the two fields. before trying it do predict the result.
Then run the query.
now look at the result carefully it will ignore the second field values and first field name
if u r query is like this
select name age from emp_table
result would be
------------------------------------------------------
AGE
------------------------------------------------------
Sainath
Sreedhar
vijay
any one Try to find out the reason
Regards,
Vijay
|
|
Back to top |
|
|
Santorini
New User
Joined: 09 Dec 2005 Posts: 1
|
|
|
|
hmm...
db2 think the second column is the new name of the firt one..if u omit the comma between them... |
|
Back to top |
|
|
senthilssg
New User
Joined: 09 Dec 2005 Posts: 64 Location: USA
|
|
|
|
hi,
it's correct only . i aaacept with Santorini's point.
reasons :
For Alias , syantax is :
Eg: select oldname AS newname
but you can give like this also ,
Eg: select oldname newname
note the difference.. it is not necessary , you should use the keyword AS in alias , just one space followed by oldname after that new name .
This is the reason . such a o/p come , its just alias concept.
Regards,
senthil |
|
Back to top |
|
|
khamarutheen
Active Member
Joined: 23 Aug 2005 Posts: 677 Location: NJ
|
|
|
|
Hi frnd,
Have u worked db2 from basic??? ie., in ur simple select statement u may watch one query like
SELECT NAME "FIRST NAME" FROM EMP1;
so the output will b
FIRST NAME
-----------------
A
B
C
LIKE THAT...
so if u give SELECT NAME FIRSTNAME from EMP1
u get the same result
so it takes as a header field name and it goes on proceeding...
hope catched my point!!!!!!!!! |
|
Back to top |
|
|
vkrajuch
New User
Joined: 22 Jun 2005 Posts: 5 Location: hyderabad
|
|
|
|
Hi Friends,
I am new to DB2.
Thanks a lot.. for ur clarification.
Regards,
Vijay |
|
Back to top |
|
|
|