List:MySQL on Win32« Previous MessageNext Message »
From:Michael Widenius Date:October 5 1999 7:44pm
Subject:Win32 version bug ? Select returns too many rows
View as plain text  
>>>>> "Alain" == Alain Fontaine <alain@stripped> writes:

Alain> Hello,
Alain> I am running the latest Win32 shareware version (not yet registered) on
Alain> Windows98.

Alain> I have a database containing about 7 tables. The main table is called
Alain> "products", containing computer equipment.

Alain> This table contains 9 records.

Alain> When I do the following SELECT statement:


Alain> ----
Alain> select products.prod_id,products.name,products.costprice,
Alain> products.manufacturer,products.promotion,products.webpage,products.profit_pe
Alain> rcent,
Alain> products.currency,products.top_pick,manufacturer.num,manufacturer.name,
Alain> manufacturer.webpage, currencies.ISO, currencies.rate,
Alain> products.category_2,sub_categories.num,
Alain> sub_categories.name
Alain> from products, manufacturer, currencies, sub_categories
Alain> where products.manufacturer=manufacturer.num
Alain> and products.currency=currencies.ISO
Alain> and products.category_2 = sub_categories.num
Alain> and products.name LIKE '%pent%'
Alain> OR manufacturer.name LIKE '%int%'
Alain> ----

Alain> the query return 2295 rows (obviously, with 9 records in my products table,
Alain> this seems strange).

Hi!

You don't have any braces around: 

'OR manufacturer.name LIKE '%int%''

This means that you say:

'for any combination of the rows of all preceding tables', give me all 
rows that has 'int' somewhere in name.

I assume you want to do something like

...
WHERE products.manufacturer=manufacturer.num
and products.currency=currencies.ISO
and products.category_2 = sub_categories.num
and (products.name LIKE '%pent%'
     OR manufacturer.name LIKE '%int%')

Regards,
Monty



Thread
Win32 version bug ? Select returns too many rowsAlain Fontaine1 Oct
  • Re: Win32 version bug ? Select returns too many rows(Hood Gardner)1 Oct
  • Win32 version bug ? Select returns too many rowsMichael Widenius5 Oct