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

Retrieve all Common records from different tables


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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
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
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
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

Moderator Emeritus


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

PostPosted: Thu Sep 06, 2007 7:25 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Using Java/C/C++ to retrieve dataset ... Java & MQSeries 6
Search our Forums:

Back to Top