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 Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Check Binary Values for symbols gandikk CA Products 3 Tue Mar 21, 2017 5:11 am
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am


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