Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在mysql中使用selectcase_Mysql - Fatal编程技术网

如何在mysql中使用selectcase

如何在mysql中使用selectcase,mysql,Mysql,以下是MSSQL语法,如何将其转换为mysql SELECT _nextBillingDate = UB.NextBillingDate, _billingFrequency = (CASE IFNULL(UB.BillingFrequency,0) WHEN 0 THEN _defaultBillingFrequency ELSE UB.BillingFrequency END), _isCompletelyCreditBilled

以下是MSSQL语法,如何将其转换为mysql

    SELECT          
    _nextBillingDate = UB.NextBillingDate,
    _billingFrequency = (CASE IFNULL(UB.BillingFrequency,0) WHEN 0 THEN
     _defaultBillingFrequency ELSE UB.BillingFrequency END),
    _isCompletelyCreditBilled = (CASE WHEN PO.ChargeAmount > 0 THEN 0 ELSE 1 END),
    _ownerId = PO.OwnerId   
    FROM PaymentOrder PO
    INNER JOIN UserBillingInfo UB ON PO.OwnerId = UB.OwnerId
    WHERE PO.Id = _paymentOrderId

在过程中,mysql使用
select cols into vars from…
样式语法,因此请尝试以下方法:

-- DECLARE variables at the top of your procedure

SELECT
    UB.NextBillingDate,
    CASE IFNULL(UB.BillingFrequency,0) WHEN 0 THEN _defaultBillingFrequency ELSE UB.BillingFrequency END,
    CASE WHEN PO.ChargeAmount > 0 THEN 0 ELSE 1 END,
    PO.OwnerId
INTO
    _nextBillingDate, _billingFrequency, _isCompletelyCreditBilled, _ownerId 
FROM PaymentOrder PO
INNER JOIN UserBillingInfo UB ON PO.OwnerId = UB.OwnerId
WHERE PO.Id = _paymentOrderId
mysql中的“选择*进入” mysql中不允许使用“select*into”。下面是一个绕过此限制的示例:


创建表newtable SELECT*FROM oldtable

阅读MSSQL和MySQL之间的一些差异。您可以下载可用于将MSSQL语句转换为MySQL语句的应用程序。选中mysql中的“select*into”,mysql中不允许“select*into”。下面是一个绕过此限制的示例:创建表newtable从oldtable选择*