473,883 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Wildcard doesn't match using LIKE '%' on a varchar field, wierd!

Right this has to be a Micro$oft mess-up surely...?

I'm running SQL 2k standard with SP3. I have a table which I'm trying
to query using a LIKE operator on a varchar field as follows

....
WHERE dbo.tbl_pm_proj ects.SeniorMana gerID LIKE '%'
....

In actual fact the % is passed in by the application when the user
selects "All managers" from the drop down list used to select the
Manager to filter by. If they select a manager's name from the list
it becomes LIKE 'ajames' or whatever.

BUT - the table currently contains 2972 records. If I take out the
WHERE clause the SELECT returns all records - fine - but if I put the
where clause in it returns only 1682!! I thought the % was meant to
match, and I quote the SQL server Books Online files here; "Any string
of zero or more characters." Anyone explain to me whats going on
here?

TIA
Niall
Jul 20 '05
12 10285
Hugo Kornelis <hugo@pe_NO_rFa ct.in_SPAM_fo> wrote in
news:ov******** *************** *********@4ax.c om:
For the philosophical bit: NULL is the absence of data, usually
because you don't know the data. The middle initial of William
Shakespeare is the empty (or zero-length) string, as we all know that
William Shakespeare had no middle initials. But if I ask you for the
middle initial of my brother, you'd have to answer me with NULL, as
you have no way of knowing if my brother has any middle initial and if
so, what it might be.


Or if you even have a brother. :)
Jul 20 '05 #11
Hi,

I had a problem similar to the one mentioned above, but now
unfortunately I have a different (but related one).
I am using Access 2000 on apache and I seem to be limited in exactly
what I can do to work my way around the NULL/empty string dilemma.
Access doesnt support COALESCE, doesn't support nested statements (as
far as I can work out) and it doesn't support overloading the ISNULL
function (only has the single parameter version).
Now I know that i'd probably be better off upgrading but i'd still like
to find the work around for a simple static sql statement that looks
something like this.

SELECT Name, Size, Age, Keyword
FROM Gdatabase
WHERE Gdatabase.Name LIKE '$name'
OR Gdatabase.Size LIKE '$size'
AND Gdatabase.Age LIKE '$age'
AND Gdatabase.Keywo rd LIKE '$keyword'

suggested solution ...

SELECT ...
FROM ...
WHERE ...
OR ...
AND ISNULL(Gdatabas e.Size,' ') LIKE '$size'
AND ISNULL(Gdatabas e.Age,' ') LIKE '$age'
...

gives me driver error ... wrong number of arguments used in function.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #12
On 14 Oct 2004 04:28:39 GMT, dara burke wrote:
AND ISNULL(Gdatabas e.Age,' ') LIKE '$age'
..

gives me driver error ... wrong number of arguments used in function.


In Access, ISNULL() is a VBA function that returns true if its single
argument is null. Try

IIF(ISNULL(Gdat abase.Age),' ',Gdatabase.Age )

That's how it would work from inside an actual Access database running in
the access program; I am not sure how Apache will respond.
Jul 20 '05 #13

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

Similar topics

5
10780
by: Aaron C | last post by:
Hi, I'm trying to do an insert with the following statement: INSERT INTO user VALUES ( 'ag@ag.com','ag','Aaron','Chandler','','','La Mirada','CA',90638,714,'',''); and I'm getting the error message "Column count doesn't match value count at row 1".
5
7438
by: Robert Brown | last post by:
I have researched newsgroups and the web very thoroughly and unsuccessfully for a solution to what I believe is a very common problem. I know it's easy to do wildcard match against data in DB (using LIKE and "%" and "?"). But is it possible to match a concrete string against a database of wildcarded data? ("%" and LIKE do not work). For example: CREATE TABLE blacklist (
1
7286
by: deko | last post by:
I have a form where users can enter a string with asterisks to perform a wildcard search. Currently, the string entered by the user looks like this: *somestring* The purpose is to match any database field containing "somestring". Is there a way to avoid the need for the asterisks? This would make it easier for the users and also I wouldn't have to explain that asterisks are required when performing a wildcard search.
3
2285
by: george.lengel | last post by:
Hello experts, I have been struggling for days to solve this problem and every suggestion I find via Google does not work for me. There is probably a solution out there that will do what I want, but I probably have not properly implemented the solutions I find. I am trying to make a page to allow personnel the ability to search our backend DB (which is Ingres 2.0) through a web interface. Ingres has a cgi program called ICE that can...
78
4661
by: wkehowski | last post by:
The python code below generates a cartesian product subject to any logical combination of wildcard exclusions. For example, suppose I want to generate a cartesian product S^n, n>=3, of that excludes '*a*b*' and '*c*d*a*'. See below for details. CHALLENGE: generate an equivalent in ruby, lisp, haskell, ocaml, or in a CAS like maple or mathematica. #------------------------------------------------------------------------------- # Short...
7
11004
by: eddie.holder | last post by:
Hi ladies and gents. I'm hoping anyone will be able to help me in a small access problem I am having. Let me try to explain: I have a form with textboxes which I use as criteria for a query. The form is used to allow my users to search for specific company names or if left blank, all the company names, so I built my criteria as follows: Like .. & chr(42) The form works ok if I am looking for a spesific company name, but when left...
0
4104
by: tania | last post by:
i have this table in my database: CREATE TABLE FILM( F_ID INT(5) NOT NULL AUTO_INCREMENT, F_TITLE VARCHAR(40) NOT NULL, DIRECTOR_FNAME VARCHAR(20) NOT NULL, DIRECTOR_LNAME VARCHAR(20) NOT NULL, TYPE VARCHAR(30) NOT NULL, DURATION TIME , YEAR_RELEASE YEAR NOT NULL, DESCRIPTION TEXT,
11
6535
by: ABC | last post by:
How to rename files with support wildcard ?
4
5790
by: kcddoorman | last post by:
I'm trying to make a multi criteria server filter and everything works fine when filtering for strings. When I add a number field to the filterable set I run into problems. Here is the VBScript I'm using. <SCRIPT language=vbscript> Function SetServerFilter() dim myFilter, strCustomer, strJobName, strSalesPerson, strWorkOrder If txtCustomer.value = "" Then strCustomer = " like '%'" Else strCustomer = " = '" & txtCustomer.value & "'"
0
9933
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
11123
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
10734
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...
0
10407
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
9567
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
7960
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...
0
5982
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4606
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
3230
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.