Using the distinct function in SQL

前端 未结 18 921
無奈伤痛
無奈伤痛 2021-02-06 16:55

I have a SQL query I am running. What I was wanting to know is that is there a way of selecting the rows in a table where the value in on one of those columns is distinct? When

18条回答
  •  醉话见心
    2021-02-06 17:33

    I'm not sure if I am understanding this right but couldn't you do

    SELECT * FROM class WHERE teacher IN (SELECT DISTINCT teacher FROM class)
    

    This would return all of the data in each row where the teacher is distinct

提交回复
热议问题