MySQL Forums
Forum List  »  Italian

count(*) non funziona...
Posted by: Pietro Torrente
Date: December 01, 2021 10:02AM

Ciao a tutti. Ho creato una stored procedure come segue:

CREATE DEFINER=`root`@`localhost` PROCEDURE [procedure_name](
idaccount int,
data NVARCHAR(10)
)
BEGIN

IF idaccount IS NULL THEN
SELECT count(*) INTO @counter FROM [table_sample]
WHERE DATE_FORMAT(STR_TO_DATE(DataInizio, '%d/%m/%Y'), '%d/%m/%Y') >= DATE_FORMAT(STR_TO_DATE(data, '%d/%m/%Y'), '%d/%m/%Y') ORDER BY DataInizio DESC;
ELSE
SELECT count(*) INTO @counter FROM [table_sample]
WHERE IDAccount = idaccount AND DATE_FORMAT(STR_TO_DATE(DataInizio, '%d/%m/%Y'), '%d/%m/%Y') >= DATE_FORMAT(STR_TO_DATE(data, '%d/%m/%Y'), '%d/%m/%Y') ORDER BY DataInizio DESC;
END IF;

SELECT @counter;

...

Mi dite perché @counter è sempre 0, quando dovrebbe restituire 6, dato che nella tabella [table_sample] ci sono 6 records?
Anche se metto [schema].[table_sample] il risultato è sempre 0. Perché? Cosa sbaglio?
Grazie!

Options: ReplyQuote


Subject
Views
Written By
Posted
count(*) non funziona...
83
December 01, 2021 10:02AM
57
December 02, 2021 02:05AM
62
December 03, 2021 05:20AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.