• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 290
  • Last Modified:

sql select statement

Hi Expert,

I have table student, I need select all student have same first name and last name, how I can do it?


student

Id  FName  LName
1    Mary       Lee
2    John       Stull
3    Mary       Lee

0
dshi15
Asked:
dshi15
  • 2
  • 2
1 Solution
 
mrjoltcolaCommented:
select * from student where fname = lname
0
 
mrjoltcolaCommented:
Or, find students with the same name?

select * from student a join student b on a.fname = b.fname and a.lname = b.lname and a.id <> b.id
0
 
dqmqCommented:
Select * from student where id in
    (select id from student where count(*) > 1 group by fname, lname)  


0
 
dqmqCommented:
Or...

Select s1.* from student s1 where exists
  (select 1 from student s2 where s2.fname = s1.fname and s2.lname = f1.lname and s1.id <> s2.id)

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now