Click here to get back home

Different results in mysql & mysql query browser?

 HomeNewsGroups | Search | About
 mailing.database.mysql    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Different results in mysql & mysql query browser? taras.di 04-18-2006
Get Chitika Premium
Posted by taras.di on April 18, 2006, 9:05 am
Please log in for more thread options
Hi everyone,

I've come across an extremely strange problem. The exact same query in
both mysql command line client, and mysql query browser gives entirely
different results. I was hoping someone out there could shed some
light.

Ok, the query (I've stripped it bare, the real query is a bit more
complex)...

Each person in the people table has an associated 'place', which is an
integer that maps onto a suburb in the suburbs table. The 'place' CAN
be NULL.

so, for all intensive purposes, the schema is roughly:

people:
personId int unsigned not null auto_increment
place int

suburbs
locationId int unsigned not null auto_increment
suburbName varchar(50) not null

QUERY
------------------------------------------------------
SELECT DISTINCT (personId),place
FROM suburbs, people
WHERE
(
people.place = suburbs.locationId //mapping the place integer
to a suburb name
)
OR
(
people.place IS NULL
AND suburbs.locationId = 1
)

Why do I set suburbs.locationId = 1? Because we are doing a cartesian
join, we don't want an entire suburbs table for each entry in the
people table where the place is null - ie: it ensures that each line in
the person table is associated with exactly one line in the suburbs
table. Since we don't care about the suburb name when the place is
null, we put in a mock value.

In MySQL query browser, I get 21 results. When I copy and paste the
query into a command line instance of MySQL, I get the (required)
result of 95.

If I delete the line 'AND suburbs.locationId = 1', I get the required
result of 95 in both query browser and mysql command line.

Anyone have any ideas?

Cheers

Taras

Version info:

MySQL version: 5.0.19-nt via TCP/IP
MySQL Query Browser version: 1.1.20


Similar ThreadsPosted
Can you help with 'MySQL Query Browser'? February 1, 2006, 11:47 pm
very complex query produces wrong results April 10, 2006, 6:08 pm
PUBLICATION RESULTS!!!!!!!!!!! May 25, 2007, 6:11 am
incorrect SELECT results February 13, 2006, 10:28 pm
Timediff() and negative results March 25, 2006, 8:51 pm
fishing tournament results May 11, 2006, 9:12 am
Ordering select results by column August 22, 2005, 1:42 am
Full text not returning any results January 11, 2006, 5:45 pm
Combining results from two pairs of tables May 7, 2006, 11:03 pm
Maybe simple - group by / having restriction - but then show all results. March 15, 2006, 7:48 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap