SQL - Ordering table with subquery for select
That is a JOIN query if I ever saw one.
You cannot pass a table or column name as a parameter in either PDO or MYSQLI. The database cannot compile and optimise code with unknown columns or tables in it
SELECT b.*, u.name
FROM bans b
LEFT JOIN users u ON u.uuid = b.uuid
ORDER BY u.name;
maybe you can try this
select a.id, a.uuid, a.time, a.reason, b.name from bans a
left join users b
on a.uuid = b.uuid
order by b.name;