I am not sure how to do write query in sql.
This is what I have tried so far.
where
case
when a.book_id like 'AB%' then a.book_id = b.school_id, --1
when a.book_id like 'CB%' then a.book_id = b.college_id. --2
end
case 1 and 2 explanation.
1- I believe is good.
2- when a.book
start with letter CB e.g CBQ123
then just take Q123
= b.college_id
.
b.college_id don't have CB in front of it.
Edit to add example
select
a.Name,
a.ID,
a.Due,
b.school_id,
b.college_id
from Student a and FinishedStudent b
where
case
when a.book_id like 'AB%' then a.book_id = b.school_id, --1
when a.book_id like 'CB%' then a.book_id = b.college_id. --2
end
if a.book = CBQ111 then Q111 is in FinishedStudent table not CBQ11,so I need to just compare last 3 character.
edit with case 2 example
when a.book_id ='CBQ111' then a.book_id(Q111) = b.college_id. --2