multiple condition in where clause
Posted by:
Date: October 24, 2008 06:08PM
Hi everybody,
I hope someone can help me please to solve this following problem about a query...
From this list of elements.....
+.id..+.city.+.date.......+.description.........+.category
+-----+------+------------+---------------------+------+
| 51 | 1 | 2005-12-13 | description_text_1 | 2 |
| 52 | 23 | 2005-12-12 | description_text_2 | 2 |
| 53 | 3 | 2005-12-12 | description_text_3 | 2 |
| 63 | 2 | 1998-05-16 | description_text_4 | 2 |
| 79 | 2 | 2004-10-16 | description_text_5 | 3 |
| 64 | 23 | 1992-02-09 | description_text_6 | 2 |
| 65 | 25 | 2001-02-14 | description_text_7 | 2 |
| 66 | 26 | 2000-01-18 | description_text_8 | 2 |
| 68 | 28 | 1993-10-12 | description_text_9 | 2 |
| 69 | 27 | 1995-04-21 | description_text_10 | 2 |
| 81 | 2 | 2008-12-14 | description_text_11 | 4 |
| 73 | 2 | 2004-12-12 | description_text_12 | 2 |
| 78 | 2 | 1998-04-04 | description_text_13 | 1 |
| 82 | 26 | 1998-10-10 | description_text_14 | 6 |
please, how can I obtain the list of records with category equal to 1, 2 and 3 only?
For istance I would have to obtain this following result
+.id..+.city.+.date.......+.description.........+.category
+-----+------+------------+---------------------+------+
| 51 | 1 | 2005-12-13 | description_text_1 | 2 |
| 52 | 23 | 2005-12-12 | description_text_2 | 2 |
| 53 | 3 | 2005-12-12 | description_text_3 | 2 |
| 63 | 2 | 1998-05-16 | description_text_4 | 2 |
| 79 | 2 | 2004-10-16 | description_text_5 | 3 |
| 64 | 23 | 1992-02-09 | description_text_6 | 2 |
| 65 | 25 | 2001-02-14 | description_text_7 | 2 |
| 66 | 26 | 2000-01-18 | description_text_8 | 2 |
| 68 | 28 | 1993-10-12 | description_text_9 | 2 |
| 69 | 27 | 1995-04-21 | description_text_10 | 2 |
| 73 | 2 | 2004-12-12 | description_text_12 | 2 |
| 78 | 2 | 1998-04-04 | description_text_13 | 1 |
...and I would to obtain all this by unique query statement.
How can I do it?
I have tried with a query similar as this but without success:
SELECT t1.id,
t1.date,
t2.city,
t2.county,
t1.description,
t1.category
FROM t1, t2
WHERE t1.category = 1 || 2 || 3
AND t1.city = t2.city_id ORDER BY t1.date DESC
but obtain a long result like this
(I have written here only the first two fields column)
81 2008-12-14
81 2008-12-14
81 2008-12-14
81 2008-12-14
81 2008-12-14
81 2008-12-14
81 2008-12-14
81 2008-12-14
81 2008-12-14
81 2008-12-14
81 2008-12-14
81 2008-12-14
81 2008-12-14
51 2005-12-13
51 2005-12-13
51 2005-12-13
51 2005-12-13
51 2005-12-13
51 2005-12-13
51 2005-12-13
51 2005-12-13
51 2005-12-13
51 2005-12-13
51 2005-12-13
51 2005-12-13
51 2005-12-13
52 2005-12-12
52 2005-12-12
53 2005-12-12
...etc...etc
How can I resolve this problem?
many thanks.
Frank.
Subject
Written By
Posted
multiple condition in where clause
October 24, 2008 06:08PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.