Are you talking about beauty?
Next, I'm setting up a procedure, where I enter as a parameter the number of rows it will return and if it is 0 or it is blank, it returns all possible rows, however in my logic it is giving syntax error and then needed of your opinion. Here's what I've done:
CREATE DEFINER='root'@'localhost' PROCEDURE 'consultarPostagens'(
in cat varchar(40),
in limite int(11)
)
BEGIN
select * from tb_post where
( case when cat is null or cat = '' then categoria is not null
else categoria = cat end) and
( case when limite > 0 or limite <> '' then limit limite end )
END
In short, the procedure returns all posts and if a category is defined, it brings up all posts in that category.
The problem is at the limit, I do not know why I can not put the term ' limit ' in it, it's the syntax error.
If anyone has any idea how to do this or how to write this command, I would appreciate it.
Valeus!