473,626 Members | 3,247 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sql statement

Can someone tell me why my query returns nothing?

"Select EmployeeID, SSN, LastName, FirstName, Address, City, State, Zipcode,
Phone from Employee where MiddleName ='' "

However this works fine.
"Select EmployeeID, SSN, LastName, FirstName, Address, City, State, Zipcode,
Phone from Employee where MiddleName ='M' "

I have checked the Employee table and I have several records with no value
in the MiddleName column.

I am using MS Access'

Please help this is driving me crazy.
May 24 '06 #1
19 1284
Are you sure you don't need to use a LIKE

For Middle Names that begin with:
"Select EmployeeID, SSN, LastName, FirstName, Address, City, State, Zipcode,
Phone from Employee where MiddleName like 'M%' "

For Middle Names that contain (any where)
"Select EmployeeID, SSN, LastName, FirstName, Address, City, State, Zipcode,
Phone from Employee where MiddleName like '%M%' "

For Middle Names that end with...
"Select EmployeeID, SSN, LastName, FirstName, Address, City, State, Zipcode,
Phone from Employee where MiddleName like '%M' "
-Wayne
"momo" <ma***@seeourwe b.com> wrote in message
news:uO******** ******@TK2MSFTN GP04.phx.gbl...
Can someone tell me why my query returns nothing?

"Select EmployeeID, SSN, LastName, FirstName, Address, City, State,
Zipcode, Phone from Employee where MiddleName ='' "

However this works fine.
"Select EmployeeID, SSN, LastName, FirstName, Address, City, State,
Zipcode, Phone from Employee where MiddleName ='M' "

I have checked the Employee table and I have several records with no value
in the MiddleName column.

I am using MS Access'

Please help this is driving me crazy.

May 24 '06 #2
Thank for replying Wayne.

No, I need to retrieve only the records without any MiddleName. I am looking
for blank MiddleNames.

"Wayne" <wa***@nospam.c fwebmasters.com > wrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
Are you sure you don't need to use a LIKE

For Middle Names that begin with:
"Select EmployeeID, SSN, LastName, FirstName, Address, City, State,
Zipcode, Phone from Employee where MiddleName like 'M%' "

For Middle Names that contain (any where)
"Select EmployeeID, SSN, LastName, FirstName, Address, City, State,
Zipcode, Phone from Employee where MiddleName like '%M%' "

For Middle Names that end with...
"Select EmployeeID, SSN, LastName, FirstName, Address, City, State,
Zipcode, Phone from Employee where MiddleName like '%M' "
-Wayne
"momo" <ma***@seeourwe b.com> wrote in message
news:uO******** ******@TK2MSFTN GP04.phx.gbl...
Can someone tell me why my query returns nothing?

"Select EmployeeID, SSN, LastName, FirstName, Address, City, State,
Zipcode, Phone from Employee where MiddleName ='' "

However this works fine.
"Select EmployeeID, SSN, LastName, FirstName, Address, City, State,
Zipcode, Phone from Employee where MiddleName ='M' "

I have checked the Employee table and I have several records with no
value in the MiddleName column.

I am using MS Access'

Please help this is driving me crazy.


May 24 '06 #3
Try using where len(ltrim(Middl eName)) = 0...
May 24 '06 #4
momo wrote:
Can someone tell me why my query returns nothing?

"Select EmployeeID, SSN, LastName, FirstName, Address, City, State, Zipcode,
Phone from Employee where MiddleName ='' "


Is MiddleName null?

Try "... where MiddleName = null" or "... where MiddleName is null".

I haven't used Access much, so I'm not sure on the syntax.
--
David Hogue
May 24 '06 #5
If the value is null (in the db), an empty string is NOT the same thing as
null.

I'm not super sure with access, but I think the query is

"Select EmployeeID, SSN, LastName, FirstName, Address, City, State, Zipcode,
Phone from Employee where MiddleName IS NULL"
that's the sql server syntax, I think access is the same.

"Wayne" <wa***@nospam.c fwebmasters.com > wrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. .. Are you sure you don't need to use a LIKE

For Middle Names that begin with:
"Select EmployeeID, SSN, LastName, FirstName, Address, City, State, Zipcode, Phone from Employee where MiddleName like 'M%' "

For Middle Names that contain (any where)
"Select EmployeeID, SSN, LastName, FirstName, Address, City, State, Zipcode, Phone from Employee where MiddleName like '%M%' "

For Middle Names that end with...
"Select EmployeeID, SSN, LastName, FirstName, Address, City, State, Zipcode, Phone from Employee where MiddleName like '%M' "
-Wayne
"momo" <ma***@seeourwe b.com> wrote in message
news:uO******** ******@TK2MSFTN GP04.phx.gbl...
Can someone tell me why my query returns nothing?

"Select EmployeeID, SSN, LastName, FirstName, Address, City, State,
Zipcode, Phone from Employee where MiddleName ='' "

However this works fine.
"Select EmployeeID, SSN, LastName, FirstName, Address, City, State,
Zipcode, Phone from Employee where MiddleName ='M' "

I have checked the Employee table and I have several records with no value in the MiddleName column.

I am using MS Access'

Please help this is driving me crazy.


May 24 '06 #6
Sorry, I misread that.

Try testing for length after triming trailing spaces. I believe the syntax
is:

"Select EmployeeID, SSN, LastName, FirstName, Address, City, State, Zipcode,
Phone from Employee where len(ltrim(Middl eName)) = 0"

"momo" <ma***@seeourwe b.com> wrote in message
news:uc******** *****@TK2MSFTNG P05.phx.gbl...
Thank for replying Wayne.

No, I need to retrieve only the records without any MiddleName. I am
looking for blank MiddleNames.

"Wayne" <wa***@nospam.c fwebmasters.com > wrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
Are you sure you don't need to use a LIKE

For Middle Names that begin with:
"Select EmployeeID, SSN, LastName, FirstName, Address, City, State,
Zipcode, Phone from Employee where MiddleName like 'M%' "

For Middle Names that contain (any where)
"Select EmployeeID, SSN, LastName, FirstName, Address, City, State,
Zipcode, Phone from Employee where MiddleName like '%M%' "

For Middle Names that end with...
"Select EmployeeID, SSN, LastName, FirstName, Address, City, State,
Zipcode, Phone from Employee where MiddleName like '%M' "
-Wayne
"momo" <ma***@seeourwe b.com> wrote in message
news:uO******** ******@TK2MSFTN GP04.phx.gbl...
Can someone tell me why my query returns nothing?

"Select EmployeeID, SSN, LastName, FirstName, Address, City, State,
Zipcode, Phone from Employee where MiddleName ='' "

However this works fine.
"Select EmployeeID, SSN, LastName, FirstName, Address, City, State,
Zipcode, Phone from Employee where MiddleName ='M' "

I have checked the Employee table and I have several records with no
value in the MiddleName column.

I am using MS Access'

Please help this is driving me crazy.



May 24 '06 #7
I tried that already and it did not work.

"David Hogue" <da************ @gmail.com> wrote in message
news:2Z******** *********@fe09. news.easynews.c om...
momo wrote:
Can someone tell me why my query returns nothing?

"Select EmployeeID, SSN, LastName, FirstName, Address, City, State,
Zipcode,
Phone from Employee where MiddleName ='' "


Is MiddleName null?

Try "... where MiddleName = null" or "... where MiddleName is null".

I haven't used Access much, so I'm not sure on the syntax.
--
David Hogue

May 24 '06 #8
Did not work

"Brad Roberts" <Br************ *****@hotmail.c om> wrote in message
news:2E******** *************** ***********@mic rosoft.com...
Try using where len(ltrim(Middl eName)) = 0...

May 24 '06 #9
Still won't work

"Wayne" <wa***@nospam.c fwebmasters.com > wrote in message
news:Ob******** ******@TK2MSFTN GP04.phx.gbl...
Sorry, I misread that.

Try testing for length after triming trailing spaces. I believe the
syntax is:

"Select EmployeeID, SSN, LastName, FirstName, Address, City, State,
Zipcode, Phone from Employee where len(ltrim(Middl eName)) = 0"

"momo" <ma***@seeourwe b.com> wrote in message
news:uc******** *****@TK2MSFTNG P05.phx.gbl...
Thank for replying Wayne.

No, I need to retrieve only the records without any MiddleName. I am
looking for blank MiddleNames.

"Wayne" <wa***@nospam.c fwebmasters.com > wrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
Are you sure you don't need to use a LIKE

For Middle Names that begin with:
"Select EmployeeID, SSN, LastName, FirstName, Address, City, State,
Zipcode, Phone from Employee where MiddleName like 'M%' "

For Middle Names that contain (any where)
"Select EmployeeID, SSN, LastName, FirstName, Address, City, State,
Zipcode, Phone from Employee where MiddleName like '%M%' "

For Middle Names that end with...
"Select EmployeeID, SSN, LastName, FirstName, Address, City, State,
Zipcode, Phone from Employee where MiddleName like '%M' "
-Wayne
"momo" <ma***@seeourwe b.com> wrote in message
news:uO******** ******@TK2MSFTN GP04.phx.gbl...
Can someone tell me why my query returns nothing?

"Select EmployeeID, SSN, LastName, FirstName, Address, City, State,
Zipcode, Phone from Employee where MiddleName ='' "

However this works fine.
"Select EmployeeID, SSN, LastName, FirstName, Address, City, State,
Zipcode, Phone from Employee where MiddleName ='M' "

I have checked the Employee table and I have several records with no
value in the MiddleName column.

I am using MS Access'

Please help this is driving me crazy.



May 24 '06 #10

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

Similar topics

28
3575
by: Fábio Mendes | last post by:
I'm sorry if it's an replicate. Either my e-mail program is messing with things or the python-list sent my msg to /dev/null. I couldn't find anything related in previous PEP's, so here it goes a very early draft for a new "assert" syntax: This was inspired in Ruby's assert syntax. I'm not familiar with Ruby at all, so the chances are that this piece of code is broken, but I think the idea is very obvious. In Ruby, assert is simply a...
15
2794
by: Nerox | last post by:
Hi, If i write: #include <stdio.h> int foo(int); int main(void){ int a = 3; foo(a); }
13
2552
by: eman1000 | last post by:
I was recently looking at the prototype library (http://prototype.conio.net/) and I noticed the author used the following syntax: Object.extend(MyObj.prototype, { my_meth1: function(){}, my_meth2: function(){} }); to define new methods on the MyObj prototype object. Object.extend
37
3281
by: Steven Bethard | last post by:
The PEP below should be mostly self explanatory. I'll try to keep the most updated versions available at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt http://ucsu.colorado.edu/~bethard/py/pep_create_statement.html PEP: XXX Title: The create statement
18
2705
by: Steven Bethard | last post by:
I've updated the PEP based on a number of comments on comp.lang.python. The most updated versions are still at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt http://ucsu.colorado.edu/~bethard/py/pep_create_statement.html In this post, I'm especially soliciting review of Carl Banks's point (now discussed under Open Issues) which asks if it would be better to have the create statement translated into:
28
2931
by: Steven Bethard | last post by:
Ok, I finally have a PEP number. Here's the most updated version of the "make" statement PEP. I'll be posting it shortly to python-dev. Thanks again for the previous discussion and suggestions! PEP: 359 Title: The "make" Statement Version: $Revision: 45366 $ Last-Modified: $Date: 2006-04-13 07:36:24 -0600 (Thu, 13 Apr 2006) $
7
2686
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about the goals -- the make statement is mostly syntactic sugar for:: class <name> <tuple>: __metaclass__ = <callable>
19
8359
by: Steve | last post by:
ASP error number 13 - Type mismatch with SELECT...FOR UPDATE statement I got ASP error number 13 when I use the SELECT...FOR UPDATE statement as below. However, if I use SELECT statement without FOR UPDATE, it is fine and no error. I also tried Set objRs = objConn.Execute("SELECT * FROM EMP UPDATE OF EMPNO"), but it still couldn't help. any ideas? I tried to search in the web but couldn't find similar
18
7957
by: dspfun | last post by:
Hi! The words "expression" and "statement" are often used in C99 and C- textbooks, however, I am not sure of the clear defintion of these words with respect to C. Can somebody provide a sharp defintion of "expression" and "statement"? What is the difference between an expression and a statement?
23
2058
by: florian.loitsch | last post by:
According to the spec Section 14 the production SourceElements:SourceElements SourceElement is evaluated as follows: 1. Evaluate SourceElements. 2. If Result(1) is an abrupt completion, return Result(1) 3. Evaluate SourceElement. 4. Return Result(3). If I understood correctly the following program should alert 'undefined': alert(eval('3;;'));
0
8711
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
8642
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
8512
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
7203
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
6125
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
4094
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...
1
2630
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
1
1815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1515
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.