you have `WHERE s.sesid` but the code above is `WHERE s.sessid`

your typo?