且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何根据具有相同`id`的另一行有效地选择列的字段?

更新时间:2023-08-28 15:30:52

一个加入与子查询

A SELF JOIN might be of help and is usually a preferable solution to lots of nested queries, if not for performance reasons (see: Join vs. sub-query, Rewriting Subqueries as Joins) certainly for readability.

在您的情况下,请尝试:

In your case try:

SELECT movies_ru.title 
 FROM movies AS movies_ru 
 JOIN movies AS movies_en 
 ON movies_ru.id = movies_en.id
 WHERE movies_ru.lang = "ru"
 AND movies_en.lang = "en"
 AND movies_en.title = "The English Title"