473,762 Members | 8,011 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join on alias field values on-the-fly

Hi,

Is it possible to join on an alias for a field value on-the-fly.
Something like the nz() function, but not only for Null values. I want
it to be for anything I stipulate as equivalent.

For example:

tblOne
------------------------------------
ColA | colB | colC
------------------------------------
A1 | B1 | Foo
A2 | B2 | Null
A3 | B3 | Bar
A4 | B4 | Foo
A5 | B5 | Foo
A6 | B6 | Foo
tblTwo
------------------------------------
ColA | colB | colC
------------------------------------
A1 | B1 | Null
A2 | B2 | Null
A3 | B3 | Bar
A4 | B4 | Null
A5 | B5 | Null
A6 | B6 | Null
When I join tblOne and tblTwo, I want it to say that if tblOne colC has
value "Foo" its equivalent to "Null" so if I join on that then it will
see it as a match and appear in the SELECT query.

Thanks

Nov 9 '06 #1
8 1645
ja********@gmai l.com wrote:
When I join tblOne and tblTwo, I want it to say that if tblOne colC has
value "Foo" its equivalent to "Null" so if I join on that then it will
see it as a match and appear in the SELECT query.
Hon, you can't join on nulls because null isn't equal to anything, not even
another null.

This is a shot in the dark, but have you tried concatenation with the plus
operator instead of the ampersand in your join clause?

FROM tblOne INNER JOIN tblTwo ON tblOne.ColC + "match" = tblTwo.ColC +
"match"

--
Message posted via http://www.accessmonster.com

Nov 9 '06 #2
On 8 Nov 2006 19:48:41 -0800, ja********@gmai l.com wrote:

How do you know that Foo pairs up with Null? I'm thinking because
both have A1 and B1.
So use that in your join: draw a line from ColA to ColA, and from ColB
to ColB.

-Tom.
>Hi,

Is it possible to join on an alias for a field value on-the-fly.
Something like the nz() function, but not only for Null values. I want
it to be for anything I stipulate as equivalent.

For example:

tblOne
------------------------------------
ColA | colB | colC
------------------------------------
A1 | B1 | Foo
A2 | B2 | Null
A3 | B3 | Bar
A4 | B4 | Foo
A5 | B5 | Foo
A6 | B6 | Foo
tblTwo
------------------------------------
ColA | colB | colC
------------------------------------
A1 | B1 | Null
A2 | B2 | Null
A3 | B3 | Bar
A4 | B4 | Null
A5 | B5 | Null
A6 | B6 | Null
When I join tblOne and tblTwo, I want it to say that if tblOne colC has
value "Foo" its equivalent to "Null" so if I join on that then it will
see it as a match and appear in the SELECT query.

Thanks
Nov 9 '06 #3
The "Null" in this case is actaully a String with the text literal
"Null"

NOT a vbNull and not an empty field.

Granny Spitz via AccessMonster.c om wrote:
ja********@gmai l.com wrote:
When I join tblOne and tblTwo, I want it to say that if tblOne colC has
value "Foo" its equivalent to "Null" so if I join on that then it will
see it as a match and appear in the SELECT query.

Hon, you can't join on nulls because null isn't equal to anything, not even
another null.

This is a shot in the dark, but have you tried concatenation with the plus
operator instead of the ampersand in your join clause?

FROM tblOne INNER JOIN tblTwo ON tblOne.ColC + "match" = tblTwo.ColC +
"match"

--
Message posted via http://www.accessmonster.com
Nov 9 '06 #4
Ohh becuase we can have a scenario where there is other things in ColC
other than just "null" and "foo"

where ColA and ColB match. and I only want it to pick it out if ColC is
"Foo" from tblOne and ColC is "Null" from tblTwo, with ColA and ColB
the same.

Thanks.

Tom van Stiphout wrote:
On 8 Nov 2006 19:48:41 -0800, ja********@gmai l.com wrote:

How do you know that Foo pairs up with Null? I'm thinking because
both have A1 and B1.
So use that in your join: draw a line from ColA to ColA, and from ColB
to ColB.

-Tom.
Hi,

Is it possible to join on an alias for a field value on-the-fly.
Something like the nz() function, but not only for Null values. I want
it to be for anything I stipulate as equivalent.

For example:

tblOne
------------------------------------
ColA | colB | colC
------------------------------------
A1 | B1 | Foo
A2 | B2 | Null
A3 | B3 | Bar
A4 | B4 | Foo
A5 | B5 | Foo
A6 | B6 | Foo
tblTwo
------------------------------------
ColA | colB | colC
------------------------------------
A1 | B1 | Null
A2 | B2 | Null
A3 | B3 | Bar
A4 | B4 | Null
A5 | B5 | Null
A6 | B6 | Null
When I join tblOne and tblTwo, I want it to say that if tblOne colC has
value "Foo" its equivalent to "Null" so if I join on that then it will
see it as a match and appear in the SELECT query.

Thanks
Nov 9 '06 #5
ja********@gmai l.com wrote:
The "Null" in this case is actaully a String with the text literal
"Null"

NOT a vbNull and not an empty field.
Ok I'll bite. Why are you storing the string "Null" in your table? Is it
because the column disallows both nulls and zero length strings and your boss
wasn't going for "whatsit," as that would confuse the users?

--
Message posted via http://www.accessmonster.com

Nov 9 '06 #6
The Null's come from the other team.

We dont have a choice why they are storing nulls as "Null"

and our database has a string value also like "Foo" which goes to
another team as that, but in terms of comparison these need to match.

Thanks.
Granny Spitz via AccessMonster.c om wrote:
ja********@gmai l.com wrote:
The "Null" in this case is actaully a String with the text literal
"Null"

NOT a vbNull and not an empty field.

Ok I'll bite. Why are you storing the string "Null" in your table? Is it
because the column disallows both nulls and zero length strings and your boss
wasn't going for "whatsit," as that would confuse the users?

--
Message posted via http://www.accessmonster.com
Nov 9 '06 #7
ja********@gmai l.com wrote:
The Null's come from the other team.

We dont have a choice why they are storing nulls as "Null"

and our database has a string value also like "Foo" which goes to
another team as that, but in terms of comparison these need to match.
To join the two tables on column C where one table's "Foo" equals the other
table's "Null," the two teams have a conflict *they* need to resolve. Team
One can say "Since you guys don't like our 'Null' in column C when there's no
other assigned value, we'll change it to 'diamond' instead." Team Two can
say "Great idea! Our 'Foo' isn't all that descriptive for 'none of the
above' either. We'll change it to 'diamond' too." And then *you* can use an
equality in your join where what used to be Team One's "Null" now matches
what used to be Team Two's "Foo" like this:

SELECT *
FROM tblOne INNER JOIN tblTwo ON tblOne.ColC = tblTwo.ColC;

If the two teams refuse to use the muscles between their ears, they can have
an arm wrestling contest. If Team One wins, both teams use "Null" for "none
of the above" in column C. If Team Two wins, both teams use "Foo" for "none
of the above" in column C. Hon, I don't know how else to put this but if you
try to resolve *their* conflict in *your* query, you aren't using the muscles
between your ears either. Note that I'm not saying it can't be done, only
that I don't want your query to look like you don't know what you're doing.
That doesn't mean you can't join the two tables on like columns and show only
records with "Null" in one table's column C and "Foo" in the other table's
column C, like this:

SELECT *
FROM tblOne INNER JOIN tblTwo ON tblOne.ColA = tblTwo.ColA
WHERE tblOne.ColC = "Foo" AND tblTwo.ColC = "Null";

--
Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200611/1

Nov 9 '06 #8
Stab in the dark but can't you say
Select * from tblOne as A, tblTwo as B where A.ColC=B.ColC or
(a.ColC='Foo' and b.ColC='Null')
Or am I missing something??

ja********@gmai l.com wrote:
Hi,

Is it possible to join on an alias for a field value on-the-fly.
Something like the nz() function, but not only for Null values. I want
it to be for anything I stipulate as equivalent.

For example:

tblOne
------------------------------------
ColA | colB | colC
------------------------------------
A1 | B1 | Foo
A2 | B2 | Null
A3 | B3 | Bar
A4 | B4 | Foo
A5 | B5 | Foo
A6 | B6 | Foo
tblTwo
------------------------------------
ColA | colB | colC
------------------------------------
A1 | B1 | Null
A2 | B2 | Null
A3 | B3 | Bar
A4 | B4 | Null
A5 | B5 | Null
A6 | B6 | Null
When I join tblOne and tblTwo, I want it to say that if tblOne colC has
value "Foo" its equivalent to "Null" so if I join on that then it will
see it as a match and appear in the SELECT query.

Thanks
Nov 13 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2359
by: the chad | last post by:
<!--#Include Virtual="/bug/adovbs.inc"--> <title>Bug Status Board</title> <% Dim conn Set conn = Server.CreateObject("ADODB.Connection") conn.Open "Provider=SQLOLEDB; Data Source = (local); Initial Catalog = techsupportBT; User Id = sa; Password="
0
356
by: Fred | last post by:
Hi Planet! I have created a table (see test script below) I have an Id field that will contains numerical values. For reason behond my control This field has to have a constant hard coded letter V in front of it. V4789 V0023
5
2361
by: Marek Kotowski | last post by:
In MySQL online documentation there are some examples with multi-tables left joins. But all of them are like this (taken from the documentation): SELECT ... FROM table1 LEFT JOIN table2 on (table1.id = table2.id) LEFT JOIN table3 on (table1.id2 = table3.id2) LEFT JOIN table4 on (table1.id3 = table4.id3)
6
2650
by: Rowan | last post by:
Hello, I am having a problem with a join. Either I am just not seeing the obvious, it isn't possible, or I need to use a different approach. I have an application with a vsflexgrid that needs to display the following: filenumber, BL, Container_BL, BL_HBL, HBL, Container_HBL The tables look like:
0
1611
by: Faraz Ahmed | last post by:
is there a way to do inner join on null values in crystal report designer... in current scenario its not returing any rows if null values found.... as we can do that in query like x inner join y on isnull(x1,0) = isnull(y1,0) plz tell me its urgent.... faraz
0
1324
by: atulmanvar | last post by:
I am using CR Viewer in ASP.net Where i created alias table. For Example Table 2 is alis of Table 1 Master Table: relates Table 1:Field 1 Master Table: relate Table 2:Field 1 While displaying records in Master Table only Those records gets displayed where values in Field 1 of Table 1 and Table 2 (ALIAS) are same.
0
958
by: Jared | last post by:
Hi, I have noticed when I do a Left Outer Join in short form that many rows become missing as result of null values. i.e Left Outer Join (t1,t2,t3) ON (....) T3 being table with null values in It seems to be all to hard when I log a bug.
4
1547
by: Sean McIlroy | last post by:
hi all is there a way to do this ... class clown: def __init__(self): self.x = 0 self.y = ALIAS(self.x) ## FEASIBLE ? .... so that you get results like this ...
3
2065
by: kjewell23 | last post by:
Hi. I have look but can't find or understand what I need to do here. I need to join two tables together with a common field which is prdno Here is my code. please help me If I'm doing it wrong. Dim connectionstring As String connectionstring = "DRIVER=Client Access ODBC Driver (32-bit);UID=xxxxxx;PWD=xxxxxxx;System=xxx.xxx.xxx" Dim Order As Integer Order = CInt(txtOrderNumber.Text) Dim...
4
2336
by: Yogesh Sharma | last post by:
create table stuinfo(roll int,name varchar(10)) insert into stuinfo values(1,'sonia') insert into stuinfo values(2,'usha') select * from stuinfo create table marks(roll int,grade varchar) insert into marks values(1,'A') insert into marks values(2,'B') select * from marks
0
9554
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9378
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9927
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9812
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8814
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5268
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3914
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 we have to send another system
3
3510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.