Rumah > Soal Jawab > teks badan
Masukkan penerangan imej di sini Saya cuba menggabungkan dua pertanyaan ini dalam hasil paparan yang sama, tetapi sistem Mysql terus mengatakan bahawa UNION tidak boleh berada di lokasi ini. Jika kesatuan tidak berfungsi, bagaimanakah saya boleh menggabungkan dua pertanyaan ini?
P粉3294258392024-04-03 11:58:44
https://dev.mysql.com/doc/refman /8.0/en/union.html berkata:
Dalam kes anda, ia kelihatan seperti ini:
(select customer_id, points, state from customers where state = 'CA' order by points desc limit 3) union (select customer_id, points, state from customers where state = 'FL' order by points desc limit 3)
Anda juga mungkin ingin mengetahui tentang Fungsi tetingkap一个>:
select customer_id, points, state from ( select customer_id, points, state, row_number() over (partition by state order by points desc) as rownum from customers where state in ('CA','FL') ) as t where rownum <= 3