I'd like to use a prepared statement like this:
SELECT DISTINCT
z.`number`,
z.`name`
FROM (
SELECT
? AS `number`, <<<<<<<< THIS LINE FAILS
`name`
FROM `plu` AS p
WHERE p.id=?
)
AS z
Sadly, it gives an error when preparing: Unknown column 'number' in 'field list'.
If I replace the ?
with actual numbers and execute it manually, it works fine.
So, my question, is it even possible to us ? AS name
in a prepared statement?