473,399 Members | 3,888 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,399 software developers and data experts.

Help with OR and Nulls in Query

PST
Here's a problem I'm trying to deal with:

I'm working on a Frontpage 2000 website for a boat handicapping
system, built in Access 97.

What I'm trying to accomplish is:

The user enters a boat name in a text field OR a sail number in a text
field, and gets the desired boat record back (an exact match).

The problem is the tricky combination of a query with OR in the WHERE
clause, and those pesky nulls.

The Boats query looks something like this:
fIDBoat ftxBoatName ftxSailNum flgRating
1 Yuletime 74 32
2 <null> 1130 66
3 Namba <null> 78
.....

As you can see, some of the records have nulls in the two fields I'm
trying to filter by. If, for example, I enter 1130 in the Sail Number
field and leave the Boat Name field blank, I'd get record 2 and record
3 as well.

I think the problem is the query itself. Should I leave the nulls as
nulls, or covert them to a space (" ") or something else? Or should I
do something with what the user enters and get rid of the nulls there?

Bear in mind this has to go into Frontpage, and I'm stuck with the
options that program gives me. I can't custom-design a SQL string for
the ASP page.

Thanks in advance

Please respond to ptupper at intergate dot ca
Nov 12 '05 #1
1 2053
Sounds Dodgy to me.
Certainly in races I have dealt with there always seem to me a couple of
pairs of boats with the same name, so without a sail number they can't be
distinguished. Equally, if you dont enforce a name or a number you can get a
boat with no information other than her handicap.

I use
SELECT DISTINCT Boat.BoatName AS Boat, jnBoatRaceMaster.RacingNo,
ExtractNumber([RacingNo]) AS [No], jnBoatRaceMaster.BoatID FROM Boat INNER
JOIN jnBoatRaceMaster ON Boat.BoatID = jnBoatRaceMaster.BoatID WHERE
jnBoatRaceMaster.RaceMasterID = screen.activeform!RacemasterID
UNION SELECT DISTINCT jnBoatRaceMaster.RacingNo AS Boat,
ExtractNumber([RacingNo]) AS [No], Boat.BoatName, jnBoatRaceMaster.BoatID
FROM Boat INNER JOIN jnBoatRaceMaster ON Boat.BoatID =
jnBoatRaceMaster.BoatID WHERE jnBoatRaceMaster.RaceMasterID =
screen.activeform!RacemasterID
UNION SELECT DISTINCT ExtractNumber([RacingNo]) AS [No],
jnBoatRaceMaster.RacingNo AS Boat, Boat.BoatName, jnBoatRaceMaster.BoatID
FROM Boat INNER JOIN jnBoatRaceMaster ON Boat.BoatID =
jnBoatRaceMaster.BoatID WHERE jnBoatRaceMaster.RaceMasterID =
screen.activeform!RacemasterID ORDER BY Boat DESC;

The ExtractNumber strips country letters from the sail number ( We use GBR
and I think you use US) so that you can key in just the numerical part of
the sail number

Function ExtractNumber(Text As String)

Dim i As Integer
Dim Num As String

For i = 1 To Len(Text)
If IsNumeric(Mid(Text, i, 1)) Then
Num = Num & Mid(Text, i, 1)
End If
Next
If Num = "" Then
ExtractNumber = ""
Exit Function
End If

ExtractNumber = Num

End Function

Hope this helps

Phil
"PST" <ptupper at intergate dot ca> wrote in message
news:fv********************************@4ax.com...
Here's a problem I'm trying to deal with:

I'm working on a Frontpage 2000 website for a boat handicapping
system, built in Access 97.

What I'm trying to accomplish is:

The user enters a boat name in a text field OR a sail number in a text
field, and gets the desired boat record back (an exact match).

The problem is the tricky combination of a query with OR in the WHERE
clause, and those pesky nulls.

The Boats query looks something like this:
fIDBoat ftxBoatName ftxSailNum flgRating
1 Yuletime 74 32
2 <null> 1130 66
3 Namba <null> 78
....

As you can see, some of the records have nulls in the two fields I'm
trying to filter by. If, for example, I enter 1130 in the Sail Number
field and leave the Boat Name field blank, I'd get record 2 and record
3 as well.

I think the problem is the query itself. Should I leave the nulls as
nulls, or covert them to a space (" ") or something else? Or should I
do something with what the user enters and get rid of the nulls there?

Bear in mind this has to go into Frontpage, and I'm stuck with the
options that program gives me. I can't custom-design a SQL string for
the ASP page.

Thanks in advance

Please respond to ptupper at intergate dot ca

Nov 12 '05 #2

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

Similar topics

2
by: Sebastian | last post by:
The following query needs about 2 minutes to complete (finding dupes) on a table of about 10000 addresses. Does anyone have an idea on how to speed this up ? Thanks in advance !!! Sebastian
6
by: mike | last post by:
I'm doing what I thought was a simple GROUP BY summary of fairly simple data and the my numbers aren't working out Some results are showing up <NULL> when I know the data is in the database ...
0
by: LesM | last post by:
This is a change of behaviour between Access 2000 SP3 and Access 2002 SP3. I have Progress table that is linked via ODBC into Access using OpenLink Lite for Progress 9.0b. For over a year, using...
4
by: Marcus | last post by:
Wondering if it's possible to allow for Null enteries in SQL/VB code. The example below doesn't work. Am I missing something? Or, is this just not possible? strSQL = "SELECT * FROM tblData " &...
6
by: Sparticus | last post by:
I have a database that isn't very big. It has about 2400 rows in it. I try and do an update like this one below (it looks big, but it's really not if you look at it) : UPDATE jobs SET...
4
by: Edmund Dengler | last post by:
Howdy all! Just checking on whether this is the expected behaviour. I am transferring data from multiple databases to single one, and I want to ensure that I only have unique rows for some...
3
by: teddysnips | last post by:
I need a trigger (well, I don't *need* one, but it would be optimal!) but I can't get it to work because it references ntext fields. Is there any alternative? I could write it in laborious code...
2
by: Bill | last post by:
I have a 200 record database that includes a date/time field, AnnivDate, for a wedding anniversary. AnnivDate has nulls and some incorrect year data. I have been creating the Access database...
6
by: Cliff72 | last post by:
I need to fill in the nulls in the batch field the value from the record immediately preceding the null one ie replace the nulls with the preceding value until I hit a record with a value in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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.