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
 

 

Retrieve all Common records from different tables

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
anu2
Warnings : 1

New User


Joined: 10 Jun 2007
Posts: 36
Location: Chennai

PostPosted: Wed Sep 05, 2007 3:55 pm    Post subject: Retrieve all Common records from different tables
Reply with quote

Hi,

Suppose in a table there are some records which
having two common column values.
Say in a employee table i have some records where emplyee name is
Hary and salary is 5000, so i want to retrieve all those records.
Please let me know.

Regards,
anu.
Back to top
View user's profile Send private message

stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Wed Sep 05, 2007 5:42 pm    Post subject:
Reply with quote

This is a basic SQL query from a single table. It doesn't match your "tables" statement in the topic. How are multiple tables involved. Please clarify your question.
Back to top
View user's profile Send private message
psreddy
Currently Banned

New User


Joined: 18 May 2006
Posts: 4

PostPosted: Thu Sep 06, 2007 10:47 am    Post subject: have try this?
Reply with quote

Hi,

Did you try this...

Select * from Employee.


Correct me if I wrong...



Thanks,
PsReddy
Back to top
View user's profile Send private message
logeswarank
Warnings : 1

New User


Joined: 15 Oct 2006
Posts: 22
Location: Chennai

PostPosted: Thu Sep 06, 2007 11:44 am    Post subject: Re: Retrieve all Common records from different tables
Reply with quote

Hi,
Try this one
Use Group by clause then use the SALARY = 5000
If any mistake let me know i'll correct
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Thu Sep 06, 2007 6:17 pm    Post subject:
Reply with quote

Quote:

Suppose in a table there are some records which
having two common column values.
Say in a employee table i have some records where emplyee name is
Hary and salary is 5000, so i want to retrieve all those records.
Please let me know.


This is such basic SQL....

Code:

SELECT COL1, COL2, COL3, COL....
FROM empTable
WHERE name = 'Hary' AND salary = 5000
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Sep 06, 2007 7:25 pm    Post subject:
Reply with quote

Hello,

Quote:
Select * from Employee.
Correct me if I wrong...

This is wrong. . . This will select everyting in the table. . .

Quote:
Try this one
Use Group by clause then use the SALARY = 5000
If any mistake let me know i'll correct

There is no need for GROUP BY. . . The requirement was to read rows matching certain criteria. . .

Please refer to Steve's SELECT.
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 Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm


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