Solved

Sql Null

Posted on 2011-09-06
3
319 Views
Last Modified: 2012-05-12
Hey guys, i have a question.

i have an sql query

select DISTINCT UPPER(r_name) as r_name, UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + location + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng FROM dbo.pretoria where active='Yes'


my problem is here

'<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + location + '<br> Contact: ' + tel  as InfoWindowText

if my location is null it not pulling

so how can i have an if statement in that query so if loction is null it must not add the location and if it is not null add the loction to the nfoWindowText?

0
Comment
Question by:JCWEBHOST
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Accepted Solution

by:
John_Arifin earned 250 total points
ID: 36486921
+ IsNull(location,'') +
0
 
LVL 15

Assisted Solution

by:gplana
gplana earned 250 total points
ID: 36487107
'<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + isNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText
0
 
LVL 4

Expert Comment

by:AnuTiji
ID: 36487411
Hi
You can use ISNULL() function to check whether the location field is null or not. SQL query is pasted below:
select 
		DISTINCT UPPER(r_name) as r_name, 
		UPPER(address) as address, 
		area, 
		location, 
		p_code, 
		tel, 
		website, 
		'<b>'+ r_name + '</b>' + '<br>' + [address] + '<br>' + area + '<br>' + ISNULL(location,'') + '<br> Contact: ' + tel as InfoWindowText,
		Latitude as Lat, 
		Longitude as Lng
	FROM dbo.pretoria 
		 where active='Yes'

Open in new window


0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question