Sample Header Ad - 728x90

Default value as expression from other columns

0 votes
1 answer
238 views
I have 2 tables: users - user_id (int ai pk) - premium premium_subscription - subscription_id (int ai pk) - user_id (int) -> fk to user.user_id - expiration (datetime) I would like to implement a boolean value based on the fact if there's a subscription and its expiration date is ahead of the time I made the query. I made this if statement, that works in a SELECT query. However, I'm not able to implement it as the value of a table. IF(timestampdiff(SECOND, CURRENT_TIMESTAMP, (SELECT expiration FROM premium_subscription WHERE user_id = *)) > 0, 1, 0); Is there any way to apply this expression to this column? Thanks in regards! ^^
Asked by CyanBook (1 rep)
Dec 11, 2020, 01:13 PM
Last activity: May 25, 2025, 02:03 PM