MySQL Forums
Forum List  »  Source, Builds, Binaries

How to update exiting data in a table in MYSQL
Posted by: Amit Sehdev
Date: June 10, 2016 06:11AM

HI

I am new to this forumn however I have a database set up in MYSQL and everyday I insert new data into this data. But every time i insert new data into this table the old data does not update and I keep getting errors when trying to change the query.

Basically I want it to insert the new data and also update any existing values.

I have provided the query below.

Thanks

ALTER PROCEDURE [dbo].[APPEND_EPOS]
-- Add the parameters for the stored procedure here

AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here

--INSERT NEW EPOS DATA
INSERT INTO EPOS.DBO.EPOS (EPOS_PRODUCTS_ID, EPOS_SALES_VALUE, EPOS_SALES_QTY, EPOS_DATE, CUSTOMERS_ID, STORE_DISTRIBUTION, EPOS_DESCRIPTION)
Select A1.[Supply Item Nbr], A1.[EPOS Sales], A1.[EPOS Qty], A1.Daily, 542, A1.[Est EPOS Store Count] , ISNULL(A1.[Shelf Description],'') + ' ' + ISNULL(A1.Variety, '') + ' ' + ISNULL(A1.[Size Desc],'')
FROm EPOS...ASDA_EPOS_DAILY7 A1

LEFT JOIN
(SELECT DISTINCT Customers_ID, EPOS_Products_ID, CAST(EPOS_Date as Date) as EPOS_Date
from KP_EPOS.dbo.EPOS) Exis ON Exis.Customers_ID = 542 and Exis.EPOS_Products_ID = CAST(A1.[Supply Item Nbr] as Integer) and CAST(Exis.EPOS_Date as Date) = CAST(A1.Daily as Date)

WHERE
Exis.Customers_ID IS NULL
AND A1.DAILY IN (Select A2.Daily FROm ASDA_EPOS...ASDA_EPOS_DAILY7 A2 WHERE NOT A2.[EPOS Qty] =0 OR NOT A2.[EPOS Sales]=0 )
END

Options: ReplyQuote


Subject
Views
Written By
Posted
How to update exiting data in a table in MYSQL
823
June 10, 2016 06:11AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.