473,473 Members | 1,584 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

MYSQL 'NULL' cant be replased

prabirchoudhury
162 New Member
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

Expand|Select|Wrap|Line Numbers
  1. 1. if((field IS NULL), 'XX', field) 
  2. 2. ISNULL(field),'XX',field 
  3. 3. CASE WHEN field IS NULL then 'XX' else field end 
  4. 4. IF(field IS NULL,'XX',field) 
  5.  
  6.  
my origunal code down here, please any one could help.

Expand|Select|Wrap|Line Numbers
  1.  
  2. select DISTINCT d.title, d.schemecode, d.objectives, 
  3. d.eligibility, d.eligibledistricts, 
  4. date_format(f.closingdate, '%d/%m/%Y') as closedate, o.type 
  5. ,( select DISTINCT COUNT(cr.CritCode) AS Rank 
  6. from CRITERIA cr 
  7. INNER JOIN SCHCRIT sc on sc.CritCode=cr.CritCode 
  8. where sc.SchemeCode= a.schemecode 
  9. AND cr.CritCode in(71,5043, 5074, 5024, 5025, 4003, 0)) AS match_rank 
  10. ,(select IF(Description IS NULL,'XX',Description) 
  11. from CRITERIA cr 
  12. INNER JOIN SCHCRIT sc on sc.CritCode=cr.CritCode where sc.SchemeCode= a.schemecode 
  13. AND cr.CritCode = 4003) AS cost1 
  14.  
  15. FROM SCHCRIT a inner join SCHCRIT b on(a.schemecode=b.schemecode) 
  16. inner join SCHCRIT c on(a.schemecode=c.schemecode) 
  17. inner join SCHEMES d on(a.schemecode=d.schemecode) 
  18. inner join PROTECTS e on(d.protectlevel=e.protectlevel) 
  19. inner join SCHORD f on(a.schemecode=f.schemecode) 
  20. inner join personOrganisation po on (d.sourceorg=po.personid) 
  21. inner join organisation o on(po.organisationid=o.organisationid) 
  22. WHERE (a.critcode =1 or a.critcode =71) 
  23. and c.critcode in (4000, 4003, 0, 0, 0) 
  24. and b.critcode in (5000, 5043, 5074, 5024, 5025) 
  25. and e.searchresults = 'T' order by match_rank DESC, cost1 ASC
  26.  
  27.  
thanks in advanced
:)
Jul 28 '09 #1
2 2600
SLauren
60 New Member
You can try with
Expand|Select|Wrap|Line Numbers
  1. IFNULL(<field_name>,Value)
If the field is null then it will replace it with the given value.

Thanks,
Lauren
Jul 28 '09 #2
prabirchoudhury
162 New Member
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,
Expand|Select|Wrap|Line Numbers
  1. This my sub query
  2. ,(select IF(Description IS NULL,'XX',Description)  
  3. from CRITERIA cr  
  4. INNER JOIN SCHCRIT sc on sc.CritCode=cr.CritCode where sc.SchemeCode= a.schemecode  
  5. AND cr.CritCode = 4003) AS cost1  
  6.  

thanks, prabir
Jul 28 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
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...
0
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...
6
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...
4
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...
6
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...
0
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...
2
ak1dnar
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...
10
rhitam30111985
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 { ...
5
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...
0
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...
0
marktang
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,...
0
Oralloy
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,...
1
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...
0
tracyyun
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...
0
agi2029
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,...
1
isladogs
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.