473,721 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2072
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, jnBoatRaceMaste r.RacingNo,
ExtractNumber([RacingNo]) AS [No], jnBoatRaceMaste r.BoatID FROM Boat INNER
JOIN jnBoatRaceMaste r ON Boat.BoatID = jnBoatRaceMaste r.BoatID WHERE
jnBoatRaceMaste r.RaceMasterID = screen.activefo rm!RacemasterID
UNION SELECT DISTINCT jnBoatRaceMaste r.RacingNo AS Boat,
ExtractNumber([RacingNo]) AS [No], Boat.BoatName, jnBoatRaceMaste r.BoatID
FROM Boat INNER JOIN jnBoatRaceMaste r ON Boat.BoatID =
jnBoatRaceMaste r.BoatID WHERE jnBoatRaceMaste r.RaceMasterID =
screen.activefo rm!RacemasterID
UNION SELECT DISTINCT ExtractNumber([RacingNo]) AS [No],
jnBoatRaceMaste r.RacingNo AS Boat, Boat.BoatName, jnBoatRaceMaste r.BoatID
FROM Boat INNER JOIN jnBoatRaceMaste r ON Boat.BoatID =
jnBoatRaceMaste r.BoatID WHERE jnBoatRaceMaste r.RaceMasterID =
screen.activefo rm!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(T ext As String)

Dim i As Integer
Dim Num As String

For i = 1 To Len(Text)
If IsNumeric(Mid(T ext, 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.c om...
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
1723
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
28300
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 I'm no SQL expert, but if I'm summing (SUM) multiple fields and adding them together in my SELECT how does SUM handle Null? In some situations a single column in a single row is Null but and it's part of a larger GROUP BY and SUM and from looking...
0
1823
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 Access 2000 under Win98, I have been running a Make Table or Append query against this ODBC table and producing an extracted Access table. Any fields that are NULL on the source ODBC table show as NULL on the output table. The query also has an...
4
1772
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 " & _ "WHERE " & "tblData.Date = #" & !! & " Or (" & !! Is Null & ")# AND (" & strCriteria & ");"
6
10766
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 prodduedate = '1/5/2005', clientduedate = '1/5/2005', digitizingcnd = 'x', digitizingcndnonsub = '', digitizingintl = '', retrieval = '', wellsitetape = '', boardsubmissions = '', hardcopylogs = '', burningcd = '', las20 = '', metric = '', tops = '',...
4
2528
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 tables. Unfortunately, some of the rows have nulls for various columns, and I want to compare them for exact equality. => create table tmp ( bigint a,
3
3729
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 in the application, but I'd rather not! DDL for table and trigger below. TIA
2
2081
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 using data imported from an Excel file and the person entering into Excel only cared about the month and day portion and Excel added the current year to the field value. I want to produce a report that shows upcoming anniversaries using a parameter...
6
5451
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 it--then hold the next value through the next set of nulls, and so on. See example below: I wanna copy down batch "IMR138" in record ID 1, all the way to ID 10. Then copy down batch "7138" all the way to ID 20 and so on....
0
8728
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,...
0
9366
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9214
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9130
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
9059
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
8005
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...
1
6668
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3187
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
2129
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.