troubleshooting Question

I cannot figure out why this behavior in MariaDB

Avatar of Ludwig Diehl
Ludwig DiehlFlag for Peru asked on
Databases* MariaDB
15 Comments1 Solution66 ViewsLast Modified:
Hello everyone. I was trying to understand why this is happening but still can't figure it out. I try this in MariaDb 10.1. I have attached the sqldump file.
So given this query:

SELECT 
	  CONCAT(
	    LPAD((IFNULL(MAX(a.test), 0) + 1), 4, "0"),
	    " - ",
	    YEAR(NOW()),
	    " - ",	    
	    IFNULL(b.description,'')
	  ) AS numero 
FROM
	tbl_test a 
        JOIN tbl_status b USING(id_status)
WHERE 	
       a.id_type='1'
	AND a.id_status ='2'
	AND a.year = YEAR(NOW())	
	

I get "0001 - 2019 - "

However for this one:

SELECT 
	  CONCAT(
	    LPAD((IFNULL(MAX(a.test), 0) + 1), 4, "0"),
	    " - ",
	    YEAR(NOW()),
	    " - ",	    
	    IFNULL(b.description,'')
	  ) AS numero 
FROM
	tbl_test a 
        JOIN tbl_status b USING(id_status)	
WHERE 	
        a.id_type='1'
	AND a.id_status =2
	AND a.year = YEAR(NOW())	
	

I get "0001 - 2019 - status2"


Is there any explanation for this?
database.sql
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 15 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros