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
0
votes
1 answer

Case in MySql when calculated values are empty for a row

I've got a long MySql string that is intended to calculate a daily percentage of a certain value. However, if there is nothing for a specific day, it just skips that day and goes to the next one. I need it to spit out a "0" for the day that it…
user2686567
  • 23
  • 1
  • 5
0
votes
1 answer

SQLite `ifnull()` vs `coalesce()` performance

From SQLite site, The ifnull() function is equivalent to coalesce() with two arguments. Then, if I have two arguments, which one is faster?
Oriol
  • 274,082
  • 63
  • 437
  • 513
0
votes
1 answer

With PHP MYSQL Prepared Statements and IFNULL() to return all records if value = ""

I am trying to build a MySQL query using Prepared Statements that will ignore a criteria if it has been set to NULL. For example, in the below, if $a = "" and $b = "10", I want the query to return all records where column b contains the value 10 and…
Alex
  • 99
  • 2
  • 9
0
votes
1 answer

Codeigniter Active Record - WHERE inside IFNULL and COUNT

I have an application that basically simulates a locker. Inside each locker I have N racks. Inside each rack I have N boxes, N folders and N books. Some of this objects are not acessible (they have an boolean attribute called ACESSIBLE). I want to…
aseolin
  • 1,184
  • 3
  • 17
  • 35
0
votes
1 answer

MySql Toad if now rows return value

I am using mysql toad, i have a table which is empty and i am trying to return a string value if no records are found i have tried the under mention queries however none works, only an empty row is returned. Query select coalesce(stDate,'0')as…
devdar
  • 5,564
  • 28
  • 100
  • 153
0
votes
2 answers

Error handle not working - file upload check

I have a multiple image upload form on a page (up to 3) - but a user may choose to not upload 1 or more images at all. The script processing the the uploads when 1 or more are left blank gives me this error: "Warning: copy() [function.copy]:…
DMSJax
  • 1,709
  • 4
  • 22
  • 35
0
votes
2 answers

MySQL: Merge rows and returning default values

Imagine the following table: id | variant | name ----------------------- 1 | 1 | a 1 | 2 | b 1 | 3 | c 2 | 1 | d 2 | 2 | e 2 | 3 | NULL 3 | 1 | g Which SQL statement do I need to run to get…
robsch
  • 9,358
  • 9
  • 63
  • 104
0
votes
1 answer

Can I use ifnull() in On clause of inner join?

I have 2 columns in Table1: email1 and email2. I need to fetch full name by concatenation of FirstName and LastName which are in some other table and it is associated with the above mentioned email fields. But I need to make sure, if email2 field…
Krishna Kumar
  • 125
  • 1
  • 15
0
votes
1 answer

IFNULL in mysql speed issue

select IFNULL(col1, (select col2 from table2 where ...)) from table1 Will it run select for table2 if table1 would have not null value? This is a speed issue question. I have no appropriate database to check.
Yevgeniy Afanasyev
  • 37,872
  • 26
  • 173
  • 191
0
votes
1 answer

C# class getting / setting IEnumerable variable statement error

I'm receiving build errors in the class properties when getting & setting an enumeration of another class that has it's own separate getters & setters. There are two of the same errors in the get {} statement of the following code. I'm not sure as…
cetmrw791346
  • 153
  • 1
  • 3
  • 13
0
votes
1 answer

MYSQL IFNull proper usage

This is just a quick question, but when making update procedures for a table say Personinfo for example is this acceptable Update Person Set FirstName = IFNULL(_FirstName, FirstName), LastName = IFNULL(_LastName, LastName) Where PID =…
SCFi
  • 512
  • 8
  • 20
0
votes
2 answers

MySQL - Complicated CASE/WHEN Condition possible?

This question is related to my previous post: MySQL - Complicated SUMs inside Query The query is working great, summing up the totals as desired. I notice that it also ignores any records with NULL values. Current query: SELECT c.*, SUM(CASE…
coffeemonitor
  • 12,780
  • 34
  • 99
  • 149
0
votes
1 answer

MySQL “Unknown column” in subquery

SELECT hi_proins0.PROC_INST_ID_ processId, act_re_procdef.NAME_ processName, ( #Unknown column 'hi_proins0.PROC_INST_ID_' in 'where clause' SELECT IFNULL(ct,0) FROM ( SELECT COUNT(*) FROM act_hi_taskinst hi_task1 INNER…
Bodhi'maN
  • 11
  • 5
0
votes
1 answer

mysql REPLACE INTO and optional values IFNULL

I'm trying to do something like this inside of a stored procedure: REPLACE INTO mytable SET myid = `IDvalue`, mytitle = `sMyTitle`, myoptionalvalue = IFNULL(`sMyOptValue`, myoptionalvalue); But not seems to work, any idea how to do this? Thanks!
Santiago
  • 2,190
  • 10
  • 30
  • 59
0
votes
1 answer

getting nearest result within IFNULL

I've got a maintenance script which dumps a bunch of data from one db to another. I'm trying to get the data as SELECT id, IFNULL(rank1,(SELECT rank2 FROM table WHERE rank1 IS NOT NULL and rank2
pedalpete
  • 21,076
  • 45
  • 128
  • 239
1 2 3
10
11