473,809 Members | 2,742 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with simple query

I'm running MySQL version 4.1.7-nt.
When I submit the following query:

SELECT DISTINCT pet from pets;

I get:

dog
cat
lama
chicken

If however, I submit the following query:

SELECT DISTINCT pet from pets WHERE pet IN ('lama');

I get:

Empty set (0.00 sec).

Any suggestions? Thanks, Marcel


Jul 20 '05 #1
3 1577
Marcel wrote:
I get:

Empty set (0.00 sec).


I couldn't repeat that. Could you provide similar commands as I provide
below to create the table and insert test material to there which allows
to repeat your problem?

# To create test environment
create table pets(pet text);
insert into pets values('dog');
insert into pets values('dog');
insert into pets values('lama');
insert into pets values('cat');
insert into pets values('lama');

# To test it
mysql> SELECT DISTINCT pet from pets;
+------+
| pet |
+------+
| dog |
| lama |
| cat |
+------+
3 rows in set (0.00 sec)

mysql> SELECT DISTINCT pet from pets WHERE pet IN ('lama');
+------+
| pet |
+------+
| lama |
+------+
1 row in set (0.00 sec)
Jul 20 '05 #2
That works.
The difference between the two tables is that the table that was last
created, has YES for column Null and NULL for column Default, while in my
original table all columns where empty (apart from Field and Type of
course).

"Aggro" <sp**********@y ahoo.com> wrote in message
news:zk******** ******@read3.in et.fi...
Marcel wrote:
I get:

Empty set (0.00 sec).


I couldn't repeat that. Could you provide similar commands as I provide
below to create the table and insert test material to there which allows
to repeat your problem?

# To create test environment
create table pets(pet text);
insert into pets values('dog');
insert into pets values('dog');
insert into pets values('lama');
insert into pets values('cat');
insert into pets values('lama');

# To test it
mysql> SELECT DISTINCT pet from pets;
+------+
| pet |
+------+
| dog |
| lama |
| cat |
+------+
3 rows in set (0.00 sec)

mysql> SELECT DISTINCT pet from pets WHERE pet IN ('lama');
+------+
| pet |
+------+
| lama |
+------+
1 row in set (0.00 sec)

Jul 20 '05 #3
Just found it.. I loaded the data from a file, all the columns that I was
looking for started with a space...
Pretty stupid from me.
Thanks anyway, Marcel

"Marcel" <in**@nospam-bluegumdata.com .au> wrote in message
news:6%******** **********@news-server.bigpond. net.au...
That works.
The difference between the two tables is that the table that was last
created, has YES for column Null and NULL for column Default, while in my
original table all columns where empty (apart from Field and Type of
course).

"Aggro" <sp**********@y ahoo.com> wrote in message
news:zk******** ******@read3.in et.fi...
Marcel wrote:
I get:

Empty set (0.00 sec).


I couldn't repeat that. Could you provide similar commands as I provide
below to create the table and insert test material to there which allows
to repeat your problem?

# To create test environment
create table pets(pet text);
insert into pets values('dog');
insert into pets values('dog');
insert into pets values('lama');
insert into pets values('cat');
insert into pets values('lama');

# To test it
mysql> SELECT DISTINCT pet from pets;
+------+
| pet |
+------+
| dog |
| lama |
| cat |
+------+
3 rows in set (0.00 sec)

mysql> SELECT DISTINCT pet from pets WHERE pet IN ('lama');
+------+
| pet |
+------+
| lama |
+------+
1 row in set (0.00 sec)


Jul 20 '05 #4

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

Similar topics

3
3058
by: Brian Oster | last post by:
After applying security patch MS03-031 (Sql server ver 8.00.818) a query that used to execute in under 2 seconds, now takes over 8 Minutes to complete. Any ideas on what the heck might be going on? I have tested this extensively and can say for certain that installing this hot fix is what has caused the performance problem. I just don't know why or how to fix it. Brian Oster
2
2689
by: Betrock | last post by:
This is probably very simple, but I just can't see my way thru it..... Short version: keyed values(numeric)in a lookup table are stored in a main table. They are displayed as text values - the keyed values description. I need a parameter query to return a range of these values. The parameter input won't accept the 'text' version. You can do it with 'Find' because you can select 'as formatted'. But I need a range. Please, any...
1
357
by: Tero Partanen | last post by:
Hi, I have a small problem with MS ACCESS query. I want to be able to have a field, where I can input the search parameter, and then it will show me all the entires that match the parameter. I have done this already (almost) using "Select Query", where in the design view I enter the parameter in the "Criteria" field of the query (under the field that I'm using for the query), but there has to be a more simple way of doing it, ie. just...
1
1874
by: amessimon | last post by:
Hi I'm having a problem querying an XML document using Xquery, i dont know if this is the right place to post, but i couldnt find an xquery newsgroup. Ive also posted in the xml group. Ive not used xquery before and cant find much documentation online regarding the problem i am encountering. Im running the following code, which is a simple query....(ive included all of it as its short and for the sake of completeness).
20
2516
by: Development - multi.art.studio | last post by:
Hello everyone, i just upgraded my old postgres-database from version 7.1 to 7.4.2. i dumped out my 7.1 database (with pg_dump from 7.1) as an sql-file with copy-commands and to one file using insert-statements. after initalizing and starting postgres 7.4 on a different port and datadirectory, i tried to import the sql-dump with the copy statements. this import fails, but importing the dump-file with inserts took a long time but was...
0
1643
by: Daniel Crespo | last post by:
Hi to all, I'm using adodb for accessing mysql and postgres. My problem relies on the mysql access. Sometimes, when I try to execute a query (using ExecTrans method below), I get this error: 'NoneType' object has no attribute 'cursor'
5
1263
by: hubmei75 | last post by:
Hello, I have a simple table containing adresses. A sample view of the table is id name city -------------------------------- 100 Meier New York 101 Meier Tokyo 110 Olson Amsterdam
3
6095
by: Juan Antonio Villa | last post by:
Hello, I'm having a problem replicating a simple database using the binary log replication, here is the problem: When the master sends an update to the slave, an example update reads as follows: UPDATE MainInfo SET dAddress='38 Holland Blvd', dCity='miami', dState='FL', dZip='33000', dCountry='USA', dPhone='999987565', dNum='AC15857', dName='Michael A Scott' WHERE did=22'
9
5763
by: HC | last post by:
Hello, all, I started out thinking my problems were elsewhere but as I have worked through this I have isolated my problem, currently, as a difference between MSDE and SQL Express 2005 (I'll just call it Express for simplicity). I have, to try to simplify things, put the exact same DB on two systems, one running MSDE and one running Express. Both have 2 Ghz processors (one Intel, one AMD), both have a decent amount of RAM (Intel system...
30
2854
by: Einstein30000 | last post by:
Hi, in one of my php-scripts is the following query (with an already open db-connection): $q = "INSERT INTO main (name, img, descr, from, size, format, cat, host, link, date) VALUES ('$name', '$img', '$descr', '$user', '$size', '$format', '$cat', '$host', '$link', '$date')" or die(mysql_error()); And when the query gets executed i get back the following error:
0
9721
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
10637
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
10376
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
10115
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
9199
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
7660
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
5550
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...
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3014
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.