I made some research like queries for numeric range, interval query and more, but none of the answers have gave me the correct result.
For simplicity I will put the info without using ids, the database has a proper schema but I want to create a query to obtain data that fits exact integer range.
I have this table but this info is short to clarify my problem:
+------+------+--------+---------------+
| year | make | model | motor |
+------+------+--------+---------------+
| 1998 | Audi | A3 | 4 Cil 1.8 Lts |
| 1999 | Audi | A3 | 4 Cil 1.8 Lts |
| 2000 | Audi | A3 | 4 Cil 1.8 Lts |
| 2001 | Audi | A3 | 4 Cil 1.8 Lts |
| 2002 | Audi | A3 | 4 Cil 1.8 Lts |
| 2003 | Audi | A3 | 4 Cil 1.8 Lts |
| 2004 | Audi | A3 | 4 Cil 1.8 Lts |
| 2004 | Audi | A3 | 4 Cil 2.0 Lts |
| 2005 | Audi | A3 | 4 Cil 2.0 Lts |
+------+------+--------+---------------+
For example I want to obtain the motor that fits 1998 - 2004 range (4 Cil 1.8 Lts), but this query give me also 4 Cil 2.0 Lts
SELECT DISTINCT motor
FROM general G
WHERE G.year BETWEEN 1998 AND 2004
Resulted table:
+---------------+
| motor |
+---------------+
| 4 Cil 1.8 Lts |
| 4 Cil 2.0 Lts |
+---------------+
Also I want that this query returned empty if not fit exactly with the range, I created an other query trying to obtain a different result but not worked.
SELECT DISTINCT motor
FROM general G
WHERE G.year IN (1998, 2005);
Resulted table:
+---------------+
| motor |
+---------------+
| 4 Cil 1.8 Lts |
| 4 Cil 2.0 Lts |
+---------------+
Thank you all
Update:
My problem is not related with make or model parameters, I'm struggle with year range which in this specific example is obtain this result if the range is between 1998 and 2004.
Result:
+---------------+
| motor |
+---------------+
| 4 Cil 1.8 Lts |
+---------------+
If the year range is between 1998 and 2005, I want to obtain an empty result because in my table, data not fits exactly with this range.