Click here to Skip to main content
15,886,788 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone
I have a problem to convert this SQL server code to MySQL
this is my Code
SQL
MERGE INTO Table_ResidVaSell as ResidVaSell
       USING (
             Select Top 1 IDMavad,BeginDayTank From Table_Total where Tarikh>=@DateOf and IDMavad=1
             union
             Select Top 1 IDMavad,BeginDayTank From Table_TotalSell where Tarikh>=@DateOf and IDMavad=2
             union
             Select Top 1 IDMavad,BeginDayTank From Table_Sale where Tarikh>=@DateOf and IDMavad=3
              ) AS source
              ON ResidVaSell.IDMavad=source.IDMavad
    WHEN Not MATCHED THEN
    Insert (IDMavad,BeginDayTank) Values(source.IDMavad,Source.BeginDayTank);


Thank you.
Posted

O yes I can. But you will not be able to understand the codes.

You should learn MySql to do the same. Try it. If you'll get any error then post the question here.

See this[^].

--Amit
 
Share this answer
 
Please, read this: MERGE (T-SQL)[^] and you'll know what MERGE statement do ;)

As per i understand in this case data are compared on IDMavad field and if they do not match, are inserted into Table_ResidVaSell.

For further information about inserting, updateing and deleting data using Merge statement, please see here[^].
 
Share this answer
 
Comments
Raja Sekhar S 27-Sep-13 2:36am    
Nice..+5!
Maciej Los 27-Sep-13 3:01am    
Thank you, Raja ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900