0

When trying this query:

SELECT * FROM superpart WHERE
Brick_subpart_id = 603 OR 145;

The output is then:

'200', '144'
'10002', '144'
'620', '145'

Why does the '144' shows up? I do not ask for a range between 603 and 145 right? Even so, 144 is lower then 145...

4

2 回答 2

6

This is because you are not comparing 145 to anything, hence it becomes true, and your query matches all records.

The query should be

SELECT * FROM superpart WHERE
Brick_subpart_id = 603 OR Brick_subpart_id = 145;

It can be rewritten as:

SELECT * FROM superpart WHERE
Brick_subpart_id IN (603,145)
于 2012-05-17T07:22:40.633 回答
1
SELECT * FROM superpart WHERE
Brick_subpart_id In( 603 , 145)
于 2012-05-17T07:23:01.690 回答