Page 1 of 1

Help with query creating

Posted: Tue Feb 04, 2014 2:01 pm
by bagi
INSERT INTO soldItems(itemId,qty,price,buyer,date,buyerStatus,sellerStatus,address,shipType,paymentType) VALUES('$i',XXX,XXX,'$user','$time','0','0','$shipType','$paymentType');
But qty,price must get so:
SELECT cart.qty, cart.qty*items.price as price FROM cart,items WHERE cart.user='$user' AND cart.itemId='$i' AND items.id='$i';
But with conditions
SELECT IF( EXISTS( SELECT * FROM delivery WHERE deliveryId='$shipType' AND itemId='$i'), 1, 0)
AND
SELECT IF( EXISTS( SELECT * FROM paymentType WHERE шd='$paymentType' AND itemId='$i'), 1, 0)
it sould be in one query

Re: Help with query creating

Posted: Thu Feb 06, 2014 1:30 pm
by requinix
So it seems like I'm not the only one who was confused about what you wanted...

I think the best option for you is to get all the data you want into PHP variables, then use those values in your INSERT query. Not try to do multiple queries at once or whatever you are describing. Besides, you probably need some or all of that data in your code to do billing or logic or other things.