You can do it like this:
function! MoveCursor(forward)
let stop_re = 'sql\%(Keyword\|Operator\|Statement\)'
let curpos=getcurpos()
while search('\<', 'W'.a:forward)
if synIDattr(synID(line("."), col("."), 1), "name") =~ stop_re
break
endif
endwhile
if synIDattr(synID(line("."), col("."), 1), "name") !~ stop_re
call setpos('.', curpos)
endif
endfunction
nnoremap W :call MoveCursor('')<cr>
nnoremap B :call MoveCursor('b')<cr>
Where you want to stop, you configure with the stop_re
which is a regular expression, taking the syntax groups on which to stop. You can check with :echo synIDattr(synID(line('.'),col('.'),1),'name')
with the cursor on an interesting syntax definition and add it to that regular expression.
The rest is basically, search forward (or backward) for beginning of the next word, check that it matches your stop regular expression and continue or stop.