473,395 Members | 1,418 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,395 software developers and data experts.

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 1554
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**********@yahoo.com> wrote in message
news:zk**************@read3.inet.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**********@yahoo.com> wrote in message
news:zk**************@read3.inet.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
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...
2
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...
1
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....
1
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...
20
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...
0
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:...
5
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 ...
3
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:...
9
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...
30
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',...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...
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...

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.