php - If there is no value in the table, then query should return 0 -
this query
select (max(booking_id),0) bookingid booking;
if there no value in table, query should return 0. how this??
two alternatives:
using
ifnull
:select ifnull(max(booking_id),0)) bookingid booking;
using
coalesce
:select coalesce(max(booking_id),0)) bookingid booking;
explanation:
ifnull
can used in mysql. coalesce
can used in rdbmss. coalesce
returns first parameter in list not null.
Comments
Post a Comment