Jump to content

query help..


techker

Recommended Posts

Hey guys im updating a database every day with a script i did that check's a DB file and changes the prices in the pricing DB according to the file..

 

now the issue is when the product is not in the DB file it puts the prices at 0.00$ in the priciing DB..

 

is there a way to update all the products in the DB file and keep the others at the price it is already set in the pricing DB??

 

this is the query:

$sql2 = "UPDATE xcart_pricing p
LEFT JOIN TbItemInventory pp
ON p.productid = pp.XcartID
SET p.price = pp.SalesPrice2
WHERE p.productid =  pp.XcartID";
$retval = mysql_query( $sql2 );
if(! $retval )
{
  die('Could not update data: ' . mysql_error());
}
echo "Updated data successfully ";

 

TblInventory is a OBDC file uploaded from an access DB file every night(DBSync for MS Access & MySQL really cool app converts access to mysql and uploads it.)

 

the file is basically the POS system

 

So it uploads to the DB then i compare the xcart pricing DB to the TBLInventory DB ..

 

am i clear?lol

Link to comment
Share on other sites

change the word LEFT in the original query to INNER.  Your select query should look like

SELECT * FROM TbItemInventory INNER JOIN xcart_pricing ON TbItemInventory.XcartID = xcart_pricing.productid ;

 

so this should update only the products selected and not put 0.00 on the others..

Link to comment
Share on other sites

ok so this a select..i need update?

 

EDIT..i mest up wrong file..

 

this is my query to update the prices..

 

$sql4 = "UPDATE xcart_pricing p
LEFT JOIN TbItemInventory pp
ON p.productid  = pp.XcartID
SET p.price = pp.SalesPrice
WHERE p.membershipid =  1 ";
$retval4 = mysql_query( $sql4 );
if(! $retval4 )
{
  die('Could not update data: ' . mysql_error());
}


////6



$sql5 = "UPDATE xcart_pricing p
LEFT JOIN TbItemInventory pp
ON p.productid  = pp.XcartID
SET p.price = pp.SalesPrice2
WHERE p.membershipid =  5 ";

Link to comment
Share on other sites

change the word LEFT in the original query to INNER.  Your select query should look like

SELECT * FROM TbItemInventory INNER JOIN xcart_pricing ON TbItemInventory.XcartID = xcart_pricing.productid ;

"UPDATE xcart_pricing p
INNER JOIN TbItemInventory pp
ON p.productid  = pp.XcartID
SET p.price = pp.SalesPrice
WHERE p.membershipid =  1 "

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.