Let's say I have a table that looks something like this:
+----+--------------+-------+----------------+------------+ | id | product_name | price | bulk_reference | bulk_count | +----+--------------+-------+----------------+------------+ | 1 | xxxx | 11.99 | 0 | 0 | +----+--------------+-------+----------------+------------+ | 2 | zzzz | 22.99 | 0 | 0 | +----+--------------+-------+----------------+------------+ | 3 | | | 2 | 10 | +----+--------------+-------+----------------+------------+
I can select all products, etc., without any problems. However, I need to return all the products, but the lines WHERE bulk_reference > 0 should return the reference values ββof the strings for product_name and price that are not specified in the string ... In the same result set.
So, for example, my result set should look something like this:
[0] => [id] = 1 [product_name] = xxxx [price] = 11.99 [bulk_reference] = 0 [bulk_count] = 0 [1] => [id] = 2 [product_name] = zzzz [price] = 22.99 [bulk_reference] = 0 [bulk_count] = 0 [2] => [id] = 3 [product_name] = zzzz [price] = 22.99 [bulk_reference] = 2 [bulk_count] = 10
How can I do this only with MySQL?
source share