There is a two table query
SELECT w.*, u.name as user FROM words as w JOIN users as u ON (u.id = w.user_id) WHERE w.status = "approved" ORDER BY w.created_at LIMIT 5 Request select the words from the database, added by users. The task is to add the ability to include in this request a specific record by its id .
That is, the first five records + are being selected for this request; page navigation is provided for, and later, when the next page is called, the values in LIMIT change.
But you need to make it so that you can record, for example with id = 2 , output together with the first request, and not include them in subsequent ones. So make it possible?
If poorly explained: By default, all entries should be displayed as follows. as output with the request described above.
But if the GET-parameter record_id in the address bar is added, with a value of, say, 2, then an entry with id = 2 must be included in the request, even if it was not intended there.
union такой-же-selectto the end of your queryunion такой-же-select, but with where id = 2, for order by work to be possible, the subquery may need to be enclosed in brackets and make select * from it - Mike