如何将此代码从SQL Server转换为MYSQL

问题描述:

大家好

我将此SQL服务器代码转换为MySQL有问题

这是我的代码

Hi everyone
I have a problem to convert this SQL server code to MySQL
this is my Code

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);





谢谢你ou。



Thank you.

O是的,我可以。但是你将无法理解这些代码。



您应该学习MySql来做同样的事情。试试吧。如果您收到任何错误,请在此处发布问题。



请参阅 [ ^ ]。



- Amit
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


请阅读: MERGE(T-SQL) [ ^ ]你会知道MERGE的声明是做什么的;)



据我所知,在这种情况下,数据在 IDMavad 字段,如果它们不匹配,则插入 Table_ResidVaSell



有关使用合并语句插入,更新和删除数据的更多信息,请参阅 here [ ^ ]。
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[^].