我正在试图弄清楚如何在MySQL中运行将执行以下操作的查询:
这是我到目前为止所做的:
SELECT
ara.AddressNumber AS ExternalID,
ara.AddressNumber as tranId,
cus.Name AS customerRef,
cus.ExternalID LIKE '5%' AS classRef,
cus.ExternalID NOT LIKE '5%' AS classRef2,
'1' AS itemLine_quantity,
'0' AS itemLine_salesPrice
FROM
adrun_copy ara,
customers_copy cus
WHERE
ara.AAccountNumber = cus.ExternalID
答案 0 :(得分:1)
CASE WHEN cus.ExternalID LIKE '5%' THEN 'FOO' ELSE 'BAR' END As classRef
如果那真的是像int
那样的数字列,你可能需要CAST
首先将它变为varchar ...不确定MySql的规则。