0

下面是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
4

2 回答 2

2

在过程中,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
于 2013-10-15T09:49:16.437 回答
0

mysql 中的“select * into” mysql 中不允许使用“select * into”。这是一个解决此限制的示例:

CREATE TABLE newtable SELECT * FROM oldtable

于 2019-09-25T09:46:34.443 回答