I have an order system that can have several receipts associated with one order. I recently ran into a query that caused an unwanted result.
SELECT info FROM orders WHERE id IN (1, 2, 2) ORDER BY FIELD (id, 1, 2, 2);
Is there a way to return the line for order number 2 twice? At the moment, the query returns row 1, and then row 2, as expected; however, in this particular case, return to line # 2 is required.
The tables look something like this (I know that MySQL is completely invalid, just for illustration):
CREATE TABLE orders ( id int(), info VARCHAR(), ) CREATE TABLE links ( orderid int(), receiptid int() ) CREATE TABLE receipts ( id int(), otherinfo VARCHAR(), )
source share