IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

check out this funny query see how DB2 reacts


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vkrajuch

New User


Joined: 22 Jun 2005
Posts: 5
Location: hyderabad

PostPosted: Fri Dec 09, 2005 8:02 pm
Reply with quote

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
Quote:
Back to top
View user's profile Send private message
Santorini

New User


Joined: 09 Dec 2005
Posts: 1

PostPosted: Fri Dec 09, 2005 8:39 pm
Reply with quote

hmm...

db2 think the second column is the new name of the firt one..if u omit the comma between them...
Back to top
View user's profile Send private message
senthilssg

New User


Joined: 09 Dec 2005
Posts: 64
Location: USA

PostPosted: Mon Dec 12, 2005 12:58 pm
Reply with quote

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
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Mon Dec 12, 2005 1:07 pm
Reply with quote

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!!!!!!!!! icon_surprised.gif
Back to top
View user's profile Send private message
vkrajuch

New User


Joined: 22 Jun 2005
Posts: 5
Location: hyderabad

PostPosted: Tue Dec 13, 2005 9:46 am
Reply with quote

Hi Friends,

I am new to DB2.

Thanks a lot.. for ur clarification.


Regards,

Vijay
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts SCOPE PENDING option -check data DB2 2
No new posts RC query -Time column CA Products 3
No new posts Check data with Exception Table DB2 0
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
Search our Forums:

Back to Top