One simple example of MySql case statement:
This query checks if a user is adult or not from his date of birth field:
This query checks if a user is adult or not from his date of birth field:
select ID, case when ((datediff(DATE(NOW()), dob)/365)>18) then 1 else 0 end as isAdult from users;
0 comments:
Post a Comment