Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare a field with itself on same database

Status
Not open for further replies.

dave796

Technical User
Aug 21, 2005
11
0
0
Hi i know the basics of sql but have struck a problem. I am trying to write a query to display records from a database where the field1 is the same as another records field1 in the same file but field2 is different any help would be great. ps. These are text fields so I am using the like operator. Thanks
 
fields? file?

perhaps you could give us an example of data in each of field1 and field2 and show us which data should be returned

r937.com | rudy.ca
 
A starting point:
SELECT A.*, B.*
FROM yourTable A INNER JOIN yourTable B ON A.Field1=B.Field1 AND A.Field2<B.Field2

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks for the help looked up inner join got my problem sorted.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top