Mysql - multiple values and between

Posted by realshadow on Stack Overflow See other posts from Stack Overflow or by realshadow
Published on 2010-05-26T11:58:29Z Indexed on 2010/05/26 12:01 UTC
Read the original article Hit count: 236

Filed under:
|
|

Hey,

I need to select 10 products and display them. Each product has 3 different prices. The select to get the prices looks like this:

SELECT * FROM products_loans WHERE CODE IN('10X15/12', '10X15/Q10-10', '10X15/Q20-10') AND 550 BETWEEN PRICE_FROM AND PRICE_TO;

Where 550 is the base price. Now this select returns 3 rows, but I want to modify it so it will return 30 results. I dont like the idea to execute 10 queries at once. I know I can easily achieve that with "OR", but I would like to ask if there is some other more elegant way to this.

The select "should" look like this:

SELECT * FROM products_loans WHERE KOD IN('10X15/12', '10X15/Q10-10', '10X15/Q20-10') AND (550, 325, 780) BETWEEN CENA_OD AND CENA_DO;

Note that there is no "price" column or anything in the table which I could use to do a JOIN and I cant modify the table.

© Stack Overflow or respective owner

Related posts about mysql

Related posts about join