Note: If the field is of the varchar type, the conditions after the when must be enclosed by the quotation mark SELECT (CASEmarital_statusWHEN0THEN married WHEN1THEN unassociated ELSEWEIZHIEND) using the preceding statement. If the marital_status is null
Note: If the field is of the varchar type, the condition after when must be enclosed by the quotation mark SELECT (CASE marital_status WHEN 0 THEN married WHEN 1 THEN unmarried else weizhi end) AS marital_status FROM tj_archive WHERE id = D1407280006 use the preceding statement. If marital_status is an empty string (instead of null)
Note: If the field is of the varchar type, quotation marks are required for the condition after when.
SELECT (CASE 'marate_status' WHEN 0 then' married 'when 1 then' unmarried 'else' weizhi' END) AS marital_status FROM tj_archive WHERE id = 'd1407280006'
In the preceding statement, if marital_status is a null string instead of null, the query result is "married"
Finally, the correct result is:
SELECT (CASE 'marital _ status' WHEN '0' then' married 'when' 1 'then' unassociated 'else' weizhi' END) AS marital_status FROM tj_archive WHERE id = 'd1407280006'
The red part is a different sentence.