sql select statement

Posted on 2011-04-30
Medium Priority
Last Modified: 2012-05-11
Hi Expert,

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


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

Question by:dshi15
  • 2
  • 2
LVL 40

Expert Comment

ID: 35497960
select * from student where fname = lname
LVL 40

Accepted Solution

mrjoltcola earned 2000 total points
ID: 35497965
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
LVL 42

Expert Comment

ID: 35498323
Select * from student where id in
    (select id from student where count(*) > 1 group by fname, lname)  

LVL 42

Expert Comment

ID: 35498334

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)


Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question