Two Paths to Orders
The report needs orders for user_id = 1 plus all orders with status = 'paid'. Rewrite the slow mixed filter as two independent result sets, then return one de-duplicated result sorted by id.
Original query
SELECT * FROM orders WHERE user_id = 1 OR status = 'paid' ORDER BY id
Sagaidāmais izvades paraugs
Tā izskatās pareiza atbilde — tās rindu skaits ir pašai savs, tam nav jāatbilst shēmas tabulām.
| id | status | user_id | created_at |
|---|---|---|---|
| 10 | paid | 1 | 2024-02-01T10:00:00 |
| 11 | paid | 1 | 2024-02-03T12:00:00 |
| 12 | paid | 2 | 2024-02-04T09:00:00 |
Pieslēdzies, lai redzētu iesniegumu vēsturi
PieslēgtiesPieslēdzies, lai izmantotu AI mentoru
Pieslēgties