hey all i am having problem with NULL values to replace with, i have been using all the way to replace NULL value but non of those working for me. NOT NULL field is replacing with abut not the NULL field. i have tested the conditions to replace NULL in other simple query those are working but not the code bellow.
i have tryed with -
1. if((field IS NULL), 'XX', field)
-
2. ISNULL(field),'XX',field
-
3. CASE WHEN field IS NULL then 'XX' else field end
-
4. IF(field IS NULL,'XX',field)
-
-
my origunal code down here, please any one could help. -
-
select DISTINCT d.title, d.schemecode, d.objectives,
-
d.eligibility, d.eligibledistricts,
-
date_format(f.closingdate, '%d/%m/%Y') as closedate, o.type
-
,( select DISTINCT COUNT(cr.CritCode) AS Rank
-
from CRITERIA cr
-
INNER JOIN SCHCRIT sc on sc.CritCode=cr.CritCode
-
where sc.SchemeCode= a.schemecode
-
AND cr.CritCode in(71,5043, 5074, 5024, 5025, 4003, 0)) AS match_rank
-
,(select IF(Description IS NULL,'XX',Description)
-
from CRITERIA cr
-
INNER JOIN SCHCRIT sc on sc.CritCode=cr.CritCode where sc.SchemeCode= a.schemecode
-
AND cr.CritCode = 4003) AS cost1
-
-
FROM SCHCRIT a inner join SCHCRIT b on(a.schemecode=b.schemecode)
-
inner join SCHCRIT c on(a.schemecode=c.schemecode)
-
inner join SCHEMES d on(a.schemecode=d.schemecode)
-
inner join PROTECTS e on(d.protectlevel=e.protectlevel)
-
inner join SCHORD f on(a.schemecode=f.schemecode)
-
inner join personOrganisation po on (d.sourceorg=po.personid)
-
inner join organisation o on(po.organisationid=o.organisationid)
-
WHERE (a.critcode =1 or a.critcode =71)
-
and c.critcode in (4000, 4003, 0, 0, 0)
-
and b.critcode in (5000, 5043, 5074, 5024, 5025)
-
and e.searchresults = 'T' order by match_rank DESC, cost1 ASC
-
-
thanks in advanced
:)
2 2600
You can try with - IFNULL(<field_name>,Value)
If the field is null then it will replace it with the given value.
Thanks,
Lauren
thanks for your reply...
the problem is not with the
IFNULL(<field_name>,Value)
IFNULL() or IF() function to replace the NULL value but when i add this function with subquery then it wont work, my main query is working fine itself and when i added the subquery that work fine , but i wanted to sort on this subquery return but, subquery fetches with null values those comes on top with " ORDER BY ASC" sort, so wanted to put all null values on the end os the sorting .. when i am trying to replace NULL using those functions then it doesn’t replace NULL, - This my sub query
-
,(select IF(Description IS NULL,'XX',Description)
-
from CRITERIA cr
-
INNER JOIN SCHCRIT sc on sc.CritCode=cr.CritCode where sc.SchemeCode= a.schemecode
-
AND cr.CritCode = 4003) AS cost1
-
thanks, prabir
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Chris |
last post by:
Hi, sorry to post OT but i cant find the MySQL newsgroup, however i am
hoping to pick up on some expert advice from php/mysql gurus here. I'm
having some trouble performing a delete across two...
|
by: Mike Chirico |
last post by:
Interesting Things to Know about MySQL
Mike Chirico (mchirico@users.sourceforge.net)
Copyright (GPU Free Documentation License) 2004
Last Updated: Mon Jun 7 10:37:28 EDT 2004
The latest...
|
by: Matt Liverance |
last post by:
I REALLY dont want to switch to oracle :( but I cant get these tables
working any faster.
I've got 2 dedicated servers, each with a slave, all run 32gig 15k rpm
raid 5 on u320 perc raid...
|
by: James E Koehler |
last post by:
I can't get the WHILE statement to work in MySQL.
The version of MySQL that I am using is:
Ver 12.16 Distrib 4.0.6-gamma, for Win95/Win98 (i32)
running on Windows MX.
Here is the relevant...
|
by: ancelotp |
last post by:
hi,
i'm new to sql
i'd appretiate if someone would helpme out with this doudt i have
CODE:
CREATE TABLE entry (
uno int(6) NOT NULL auto_increment,
fname varchar(30) NOT NULL,
sname...
| |
by: yeahuh |
last post by:
Quick and dirty version.
Godaddy server using MySQL 4.0.24
I’m trying a left join to obtain id’s in table A(cars) that are NOT in car_id in table B(newspaper):
*This is a cut down version...
|
by: ak1dnar |
last post by:
I need to put the connection string in a global file.because again and again i cant edit the lines. if there is Global file how can call for it.in php i can use require 'dbconfle.php' ;
Like wise...
|
by: rhitam30111985 |
last post by:
hi all .. java/jdbc newbie here ... i cant seem to perform the most basic step for database connectivity using java . here is my code :
import java.sql.*;
public class connect
{
...
|
by: ScottCase |
last post by:
Hello,
I have this sql statement and it works fine with mysql v4
$query = "SELECT id, name, jv_signups, mem_signups, (
SELECT SUM( jv_signups )
) + (
SELECT SUM( mem_signups ) ) AS total...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |