I need to use subqueries to name columns in a query. I have written a statement with subqueries in the SELECT section, but I am getting the following error message (returned from Codeigniter):
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(SELECT
ps_url_nameFROMproduct_selectsWHEREps_id= '1'),psc_opt_2A' at line 1
SELECT
`psc_opt_1` AS (SELECT `ps_url_name` FROM `product_selects` WHERE `ps_id` = '1'),
`psc_opt_2` AS (SELECT `ps_url_name` FROM `product_selects` WHERE `ps_id` = '2'),
`psc_opt_3` AS (SELECT `ps_url_name` FROM `product_selects` WHERE `ps_id` = '3'),
`psc_opt_4` AS (SELECT `ps_url_name` FROM `product_selects` WHERE `ps_id` = '4'),
`psc_opt_5` AS (SELECT `ps_url_name` FROM `product_selects` WHERE `ps_id` = '5')
FROM (`product_stock_control`)
WHERE `psc_prod_id` = '5'
Filename: models/products_model.php
Line Number: 602
Any ideas what is going wrong?