troubleshooting Question

Requesting help with creating an SQL query to select similar records

Avatar of earwig75
earwig75 asked on
Microsoft SQL ServerSQL
4 Comments1 Solution82 ViewsLast Modified:
This is a little hard to explain but I will do my best.  I need to write/update the example query below  so that it will return the records requested, but also return records based on what was returned. In my example below, two records are returned with "carnumber 55". I want to show those 2 records, but also any other records with the same "carname". In my example below, 3 additional records are displayed because they have the same car name as those returned from the original query. Can someone assist?

Select id, carnumber, carname
from tblOne 
where carnumber = 55

What I want returned from the new query

id   |   carnumber   |   carname
1    |      55       |   bobs car
5    |      55       |   johns car
7    |      88       |   bobs car
8    |      77       |   bobs car
21   |      97       |   johns car
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros