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
Sampla aschuir a bhfuiltear ag súil leis
Seo é an chuma a bheadh ar fhreagra ceart — tá a líon rónna féin aige, ní gá dó na táblaí scéime a mheaitseáil.
| 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 |
Logáil isteach chun stair na n-aighneachtaí a fheiceáil
Logáil isteachLogáil isteach chun an Meantóir IS a úsáid
Logáil isteach