Hi Roger,

I took the suggestion from Brad Eacker and use BETWEEN and now works without
problem. However, I decided to do a couple more tests and what I found was
that the problem occurs on MySQL version 4.0.18-standard using InnoDB on
Linux but does not occur on Mac OS X using the same MySQL version.

Andre


On 9/20/04 5:52 PM, "Roger Baklund" <[EMAIL PROTECTED]> wrote:

> * Andre Matos
>> I am performing a SELECT and I am getting 0 rows when I run the SELECT
>> direct in the MySQL database and getting 1 when I run using PHP.
>> This is my
>> select:
>> 
>> SELECT * FROM scan WHERE TimePointID = 3 AND ScanQCResult = 'n' AND
>> (ScanStatusID < 90 OR ScanStatusID > 98);
> 
> Looks ok.
> 
>> I realized latter analyzing this select that I made a mistake using OR at
>> this point: (ScanStatusID < 90 OR ScanStatusID > 98), it should be "AND".
> 
> Are you sure about that?
> 
>> However, in both cases, I am still getting 0 rows from the database, which
>> is correct.
>> 
>> My problem is using the PHP to run the SELECT, if I use OR using
>> the PHP, I
>> got 1 as a result, and if I use AND I got 0 as a result.
> 
> This is correct, if you have one record with ScanStatusID in the range
> 90-98.
> 
>> Is anyone can tell me what is going on?
> 
> You seem to be misinterpreting how logical expressions work. A SQL select
> statement is a description of the (sub-)set of data you wish to retrieve
> from the database. This description often includes a WHERE clause,
> describing wanted records, which again often includes a logical expression.
> The expression is built up by operands and operators. The logical operators
> relevant in SQL is AND, OR and NOT. NOT is a negation, this operator takes
> one operand, the the result is the opposite of the operand. NOT true is
> false, and NOT false is true. The other two operators, AND and OR, need two
> operands, one on each side. For the AND operator, BOTH sides of the operator
> must be true for this part of the expression to be true. For the OR
> operator, ANY of the sides of the operator must be true for that part of the
> expression to be true.
> 
> So, for your expression above, you can not say ...ScanStatusID < 90 AND
> ScanStatusID > 98..., because ScanStatusID can not be below 90 AND above 98.
> ScanStatusID is a single number, it can be below 90 OR above 98. Not both at
> the same time.
> 
> --
> Roger

-- 
Andre Matos
[EMAIL PROTECTED]



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to