我有以下MySQL查詢:限制是不是在我的查詢工作
SELECT
(SELECT count(city) as no_off_total_cityies FROM station)
- (SELECT count(DISTINCT city) as no_off_total_cityies FROM station) AS sub_value
FROM station
工作正常,但是當我在查詢中添加LIMIT 1
它不工作
SELECT
(SELECT count(city) as no_off_total_cityies FROM station)
- (SELECT count(DISTINCT city) as no_off_total_cityies FROM station) AS sub_value
FROM station LIMIT 1
你能附上你得到的錯誤嗎? –
這是不正確的,「限制1」只取得第一個結果。 –
你不能嘗試這個查詢: - SELECT(count(1) - count(DISTINCT city))sub_value from station –