Mysql
 sql >> Datenbank >  >> RDS >> Mysql

MySQL - While in SELECT-Klausel

Verwenden Sie einfach CASE

select 
    `id` as 'ID',
    CASE `parentId` WHEN is not null THEN `parentId` END as 'Root ID'
from
    `item`