I am running a query from a php
file, which gets its input from the user.
Each time a user buys a product, I want to insert a new row.
What my query looks like:
INSERT INTO purchases (name, price)
SELECT product.name, product.price
WHERE product.name
IN (.........)
(and, in place of the dots, a php implode is used, and it could be
('scarf', 'jeans', 'T-shirt', 'scarf')
Now, this would be great if it did what I wanted:
When a customer buys the same product twice (say, 2 scarfs), then the
IN
condition only matches it once (obviously, it is an IN
statement...) but I would like to match it twice. That is, if a customer buys two scarfs then I want two new rows in purchases
.
Would it be possible to achieve it, without messing much with the code?