如何将此代码从SQL Server转换为MYSQL [英] How can i Convert this code from SQL server to MYSQL

查看:288
本文介绍了如何将此代码从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的声明是做什么的;)



据我所知,在这种情况下,数据在<$ c $上进行比较c> 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[^].


这篇关于如何将此代码从SQL Server转换为MYSQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆