count(*) non funziona...
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!
Subject
Views
Written By
Posted
count(*) non funziona...
143
December 01, 2021 10:02AM
98
December 02, 2021 02:05AM
116
December 03, 2021 05:20AM
A word you have used in your post has been banned from use. Please use a different word or contact the forum administrators.
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.