Questions tagged [ifnull]

This tag refers to the process of determining whether or not a particular object is null, and then running certain code based off of that condition.

Use this tag for questions related to running certain code depending on whether or not one or more objects is null.

161 questions
2
votes
4 answers

using sql - Is not null in a select statement

I can't seem to figure out how to use the opposite of isnull or ifnull statements in sql. I need to say if a.Error1 is not null -- then print the ' - ' and the + CHAR(13)+CHAR(10). Basically There should be no dash or no new line break if the…
Elizabeth
  • 719
  • 1
  • 14
  • 27
2
votes
1 answer

SQL to fetch similar "match" results by percentage

This table stores user votes between user matches. There is always one winner, one loser and the voter. CREATE TABLE `user_versus` ( `id_user_versus` int(11) NOT NULL AUTO_INCREMENT, `id_user_winner` int(10) unsigned NOT NULL, `id_user_loser`…
Andres SK
  • 10,779
  • 25
  • 90
  • 152
2
votes
2 answers

Include null results in group_concat

I have two tables like this profile_answers +---------+------------+ | id | class_name | +---------+------------+ | 1 | Class 1 | | 2 | Class 2 | | 3 | Class 1 …
Manjunath Manoharan
  • 4,567
  • 6
  • 28
  • 43
2
votes
1 answer

Can I use MySQL ifnull with a select statement?

I'm trying the following and cannot find out what is wrong: IF( IFNULL( SELECT * FROM vertreter AS ag WHERE ag.iln = param_loginID AND ag.verkaeufer = param_sellerILN ), UPDATE vertreter AS agUp SET…
frequent
  • 27,643
  • 59
  • 181
  • 333
2
votes
1 answer

ifnull not working on mysql

I have the following table: +----+------------+----------+------------------+ | id | created_at | platform | platform_version | +----+------------+----------+------------------+ | 1 | 1 | mac | 1 | | 2 | 2 |…
luis
  • 23
  • 6
1
vote
1 answer

return null row in mysql if record not found for the given id

Hi am using the below mysql query SELECT * FROM particulars pp WHERE (pp.SnoFK IN (108,999999) AND pp.curMonth = STR_TO_DATE('01/02/2012', '%d/%m/%Y')) In my table i have record for only 108, so it returns only one…
Spen D
  • 4,225
  • 9
  • 39
  • 47
1
vote
2 answers

I have only 1970-01-1.. when I use ifNull

In ClickHouse, I want to write fix 'dateTime' where column (type: DateTime64(9)) is null but I have only 1970-01-01... select Id, ifnull(event_datetime, toDateTime64('2023-06-20',9,'Etc/UTC')) as event_datetime from ... I wrote the correct timeZone…
1
vote
0 answers

Is there a way to implement IfNull/Coalesce in DynamoDB PartiQL?

DynamoDB PartiQL does not support an equivalent IFNULL/COALESCE built-in function yet (even though COALESCE is a reserved keyword and DynamoDB's sibling QLDB seems to support it with its PartiQL implementation, so it appears to be theoretically…
Grant Moore
  • 153
  • 1
  • 10
1
vote
1 answer

mysql IFNULL INSERT huge setback?

I am having a bit of a problem with some mysql. I will try to give a much background as I can. This is the situation, I had created an availability for my parent's plant nursery and stored the plant information in mysql, I did a terrible job the…
GerritVK
  • 325
  • 2
  • 11
1
vote
1 answer

Is it possible to default a value in Mongodb like $ifNull but with empty string?

A mongo operator I love to use is $ifNull, but sometimes this doesn't cover all the cases I need to cover, like for example an empty string. Is there an operator that works like the $ifNull operator (but with other conditions getting checked, like…
1
vote
1 answer

mysql - Query with IFNULL and CONCAT_WS returns empty string instead predefined IFNULL parameter in case of NULL

I am working on the complex MySQL query with subquery and JOINs and this is my query: SELECT id, ancient_source_name, ancient_source_name_alt, ancient_source_type, ancient_source_type_id, IFNULL(IF(ancient_source_material =…
Boris J.
  • 113
  • 8
1
vote
0 answers

Coalesce and IsNULL in a Concat not working with NULL valies

I am trying to create a string out of several fields, some of which can be NULL. If I do Select Concat(FieldA,IsNULL(FieldB,''),FIeldC) from Table I get 1582 - Incorrect parameter count in the call to native function 'IsNULL' If I do Select…
user3649739
  • 1,829
  • 2
  • 18
  • 28
1
vote
1 answer

How to set 0 when the count row display Null?

So, I have this sql: SELECT program.BilanganTerhad - IFNULL(COUNT(daftarprogram.KodProgram), 0) AS kiraan FROM program, daftarprogram WHERE program.KodProgram = daftarprogram.KodProgram AND daftarprogram.KodProgram = '19' How can I set the null…
Kucen
  • 11
  • 2
1
vote
2 answers

I need to show all cars from BRAND_CAR even if there is no car in it

I created this query and i can't show all brand car even with 0 vehicule created on vehicule table. SELECT BRAND_CAR_NAME, COUNT(*) FROM brand b, vehicule v, model mo WHERE v.ID_MODEL = mo.ID_MODEL AND mo.ID_BRAND = b.ID_BRAND GROUP BY…
Kovenk
  • 25
  • 3
1
vote
1 answer

Combining IFNULL, SUM and WHERE function to show available amount

I want to return the available stock value through a query where the amount on orders is deducted from total stock and where amount on order = NULL is transformed to 0. So that if there are no items open on orders, it simply shows the total stock.…
Niek
  • 11
  • 1
1 2
3
10 11