Using a SELECT statement within a WHERE clause

后端 未结 7 2101
孤街浪徒
孤街浪徒 2020-12-17 18:42
SELECT * FROM ScoresTable WHERE Score = 
  (SELECT MAX(Score) FROM ScoresTable AS st WHERE st.Date = ScoresTable.Date)

Is there a name to describe

7条回答
  •  有刺的猬
    2020-12-17 19:22

    It's not bad practice at all. They are usually referred as SUBQUERY, SUBSELECT or NESTED QUERY.

    It's a relatively expensive operation, but it's quite common to encounter a lot of subqueries when dealing with databases since it's the only way to perform certain kind of operations on data.

提交回复
热议问题