Help with query creating

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
bagi
Forum Newbie
Posts: 24
Joined: Thu Oct 31, 2013 10:50 am

Help with query creating

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Help with query creating

Post 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.
Post Reply