mysql - Get the last count result of last query -


i want use output of in if , else statement how can this?

i've tried directly putting select query if (select query) > 0 then, not work. how can achieve this?

select count(*) service, kit, kit_has_part, part  service.id = 1 , service.kitid = kit.id  , kit.id = kit_has_part.kitid  , kit_has_part.partid = part.id  , part.stock > 0 

a simple way declare variable , select result it. can use variable in if. pseudocode'ish;

create function bop() returns int deterministic begin   declare cnt int;    select count(*) cnt   service   join kit on kit.id = service.kitid   join kit_has_part on kit_has_part.kitid = kit.id   join part on part.id =  kit_has_part.partid   service.id = 1 , part.stock > 0;    if cnt > 0     return 1;   else     return 0;   end if; end; // 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -