0
Falling into the condition of if
I need to execute these two commands:
if(ultima_refeicao!=refeicao) then
SELECT refeicao_alimentos.calorias into calorias from refeicao_alimentos where refeicao_alimentos.id_Usuario=usuario ORDER BY refeicao_alimentos.idRefeicao desc limit 1;
SELECT refeicao_alimentos.carboidrato into carboidratos from refeicao_alimentos where refeicao_alimentos.id_Usuario=usuario ORDER BY refeicao_alimentos.idRefeicao desc limit 1;
SELECT refeicao_alimentos.proteina into proteinas from refeicao_alimentos where refeicao_alimentos.id_Usuario=usuario ORDER BY refeicao_alimentos.idRefeicao desc limit 1;
SELECT refeicao_alimentos.gordura into gorduras from refeicao_alimentos where refeicao_alimentos.id_Usuario=usuario ORDER BY refeicao_alimentos.idRefeicao desc limit 1;
delete from refeicao_alimentos where refeicao_alimentos.idRefeicao=refeicao and refeicao_alimentos.id_Usuario=usuario;
insert into refeicao_alimentos_log(id_Usuario,refeicoes,alimento,porcao,calorias,carboidrato,proteina,gordura,dia,metas_calorias,metas_carboidratos,metas_proteinas,metas_gorduras,desabilitar) values
(usuario,refeicao,1,0,0,0,0,0,curdate(),1,1,1,1,"s");
it is possible ....
– novic
With the question data what can be answered is with a hypothetical code that shows the declaration structure of the
PROCEDURE
and ofIF/END IF
but it probably won’t work with your database because without knowing the schematics of the tables involved, you can’t put together a specific code for your project. If serve you a hypothetical code let me know because I already have it ready but if you want something functional edit the question and put the diagram of the tables.– Augusto Vasques
Yes, please. The hypothetical code will help yes...
– Lucas Masao