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

hibernate - How to load global settings frequently used in application in Java -

objective c - Ownership modifiers with manual reference counting -

python 3.x - Mapping specific letters onto a list of words -