UNION cannot combine two results with the same column
P粉647504283
P粉647504283 2024-04-03 00:23:39
0
1
415

Enter image description here I tried to combine these two queries in the same display result, but the Mysql system keeps saying that UNION cannot be at this location. If union doesn't work, how can I combine these two queries?

P粉647504283
P粉647504283

reply all(1)
P粉329425839

https://dev.mysql.com/doc/refman /8.0/en/union.html said:

In your case it would look like this:

(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)

You may also want to knowWindow functions一个>:

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 
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!