我有mysql表电影。 如何选择价格高于'Movie3'价格的标题和价格?
例如:
Id | Title | Price
1 | Movie1 | 10
2 | Movie2 | 15
3 | Movie3 | 17
4 | Movie4 | 11
5 | Movie5 | 20
结果是
Movie3 | 17
Movie5 | 20
我试过
select Title, Price from Movies
where Price > (select Price from Movies where Title = 'Movie3')
答案 0 :(得分:2)
没有子选择的“创意”解决方案:
SELECT Title, Price from Movies m1
INNER JOIN Movies m2 ON m1.Price >= m2.Price
WHERE m2.Title LIKE "Movie3";
注意:这大于或等于movie3的价格。在你的问题中你对此有点不清楚。
答案 1 :(得分:1)
给定的价格是int类型,标题是varchar以下将起作用
SELECT title,price FROM movies WHERE price >= (SELECT price FROM test WHERE title='Movie3')