473,396 Members | 1,767 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,396 software developers and data experts.

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 1623
ja********@gmail.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********@gmail.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.com wrote:
ja********@gmail.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********@gmail.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********@gmail.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.com wrote:
ja********@gmail.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********@gmail.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.com
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********@gmail.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
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 =...
0
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...
5
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...
6
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...
0
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...
0
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...
0
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...
4
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
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. ...
4
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)...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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,...

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.