473,432 Members | 1,366 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,432 software developers and data experts.

Concat nulls in view

147 100+
Hi all,

I have a view which is used to list and amalgamate all my products. This makes a string search on a website more efficient than searching each table seperately (I think!)

However, there are no links between the 4 tables (all are seperate products) so to join the tables, I use something like: join where books.ID <> dvd.ID <> games.ID <> cd.ID

This gives me a view which lists all of my products which is what I want. The problem is the alias's. I now have 4 columns: booksID, dvdID, gamesID and cdID. So, I concatate them: (b.ID + d.ID + g.ID + c.ID) AS ConcatID. This works.

Some of the ID's can be left blank (null). Don't ask why, they just can! A perfect example of why we don't use the term ID!! Any way, this means all my ContactID fields return null.

I know I can use SET CONCAT_NULL_YIELDS_NULL ON but this doesn't appear to work in a view. I get told off SQL can't create it in the diagram.

Any ideas?
Jul 26 '10 #1

✓ answered by ck9663

In this expresssion:

Expand|Select|Wrap|Line Numbers
  1.  
  2. (b.ID + d.ID + g.ID + c.ID) AS ConcatID
  3.  
  4.  
Do you want it to return NULL or do you want it to return the values that are not NULL and just replace those NULL with blank. ie, B GC means your second ID is NULL? If that's the case, use ISNULL on each of those columns.

Happy Coding!!!

~~ CK

4 1630
ck9663
2,878 Expert 2GB
Yes.

Use ISNULL() function on your concatenated expression.

Good Luck!!!

~~ CK
Jul 26 '10 #2
DaveRook
147 100+
Thanks, but that will won't work. It appears when the fields are being added together they return null because at least 1 item is of value null. So, to do a ISNULL() will only replace the current null value with something else.

May be I'm just being lazy and should use the alias's to create 4 seperate columns in the view and then get the website to check all the columns; it just seemed to be a good way to save time by doing it in SQL
Jul 27 '10 #3
ck9663
2,878 Expert 2GB
In this expresssion:

Expand|Select|Wrap|Line Numbers
  1.  
  2. (b.ID + d.ID + g.ID + c.ID) AS ConcatID
  3.  
  4.  
Do you want it to return NULL or do you want it to return the values that are not NULL and just replace those NULL with blank. ie, B GC means your second ID is NULL? If that's the case, use ISNULL on each of those columns.

Happy Coding!!!

~~ CK
Jul 27 '10 #4
DaveRook
147 100+
Ah, thank you. I tried to do the entire thing which of course won't work... Seems so obvious now it's been pointed out. Thank you for your help and the time, this has worked perfectly. Thank you
Jul 28 '10 #5

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

Similar topics

3
by: aaj | last post by:
Hi I am probably going to regret asking this because I'm sure you are going to tell me my design is bad 8-) ah well we all have to learn.... anyway I often use Nulls as a marker to see if...
1
by: Droope | last post by:
I have a date field in a SQL table that allows null. If certain conditions are met in the user interface I need to set the field to nulls. using a typed dataset I do the following Dim...
14
by: Eli | last post by:
I've got a script that I'm trying to debug which uses document.write() to place HTML within a page. In both IE6 and Firefox when I view source, I see only the script itself and not any HTML as...
0
by: Rhino | last post by:
I am working with SQL Functions in DB2 for Windows/Linux/UNIX (V8.2.1) and am having a problem setting input parameters for SQL Functions to null in the Development Center. My simple function,...
10
by: Angel | last post by:
I want to concat a space in an HTML Control's innerText property. here is a sample code Dim celCreate As New HtmlControls.HtmlTableCell() celCreate.innerText = " TEST" When the page is...
3
by: Bob Stearns | last post by:
I am creating an index on a column which is 40% NULLS. The process seems to run forever, though a count of the number of values runs in milliseconds. This leads to the subject question: is there a...
4
by: Martin Evans | last post by:
Hi, I'm getting: DBD::DB2::db do failed: SQL0440N No authorized routine named "CONCAT" of type "FUNCTION" having compatible arguments was found. SQLSTATE=42884 for some SQL like this:
8
by: markjerz | last post by:
Hi, I basically have two tables with the same structure. One is an archive of the other (backup). I want to essentially insert the data in to the other. I use: INSERT INTO table ( column,...
1
by: M | last post by:
If I have table1 and table2 with table2 having multiple rows tied to a single row in table 1. What I am trying to do is set up a view that has one row that shows the following table1.uniqueid,...
1
by: Sharat Koya | last post by:
I have a the following xml node. <doc tag1="a" tag2="b" tag3="c" docTag1="d" docTag2="e"/> I would like to output "abc" I have the following XPATH2.0 so far //doc/@*] which returns a node...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.