Why mysql query doesn't return 0 when is null -


i'm trying return values 0 when field null. example if there 1 id_articulo importe null, query return 0.

table

create table `pujas` (   `id_puja` int(11) not null auto_increment,   `id_articulo` int(11) default null,   `id_usuario` int(11) default null,   `tiempo` timestamp not null default current_timestamp,   `importe` int(11) default null,   primary key (`id_puja`) ) engine=innodb auto_increment=3 defau  lt charset=latin1; 

query

select ifnull(max(importe),0) pujas group id_articulo 

enter image description here

you forgot 2nd argument of ifnull() function

select ifnull(max(importe), 0) pujas group id_articulo 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -