Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

check out this funny query see how DB2 reacts

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: check out this funny query see how DB2 reacts
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    Post subject: Re: check out this funny query see how DB2 reacts
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    Post subject:
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: 680
Location: NJ

PostPosted: Mon Dec 12, 2005 1:07 pm    Post subject: funny query
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    Post subject: Re: check out this funny query see how DB2 reacts
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 7 Fri Nov 18, 2016 1:48 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us