MySQL calculated column using two tables -


i've got table of clubmembers integer id (pk)

i've got table lists couple of ids (life members of club)

i want create view clubmembers, plus column calculates membership type works this:

if (clubmember.id in lifemembers) result = "life" elseif (clubmember.datejoinedclub on 1 year ago) result = "full" else result = "probationary" 

but have no idea how in sql.

use left join , case, this:

select cm.*,   case when lm.id not null 'life'        when now() > date_add(cm.datejoinedclub, interval 1 year) 'full'        else 'probationary'   end `result` clubmembers cm left join lifemembers lm on cm.id = lm.id 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -