How can I calculate the amount of numbers and only those from the date of march for instance (24/03/2016, 29/03/2016 etc.)
-
3yes, you have to use an `AND` between those conditions – Lamak Nov 03 '16 at 14:47
-
2`WHERE Price < 200 AND Types LIKE '%D%';` should solve this for you. – Jens Nov 03 '16 at 14:48
-
Your `WHERE` clause is wrongly phrased. It should be `WHERE Price <200 Types AND Like '%D%'` (note the `%` instead of `@`). – FDavidov Nov 03 '16 at 14:50
-
@FDavidov Not all RDBMS uses `%` as a wildcard . Most of them does, but not all of them. – sagi Nov 03 '16 at 14:52
-
Well, those I know do (ORACLE, MySQL, SQL-Server). And since not specific one was tagged, I selected the most common and standard (ANSI) syntax. – FDavidov Nov 03 '16 at 14:54
2 Answers
SELECT * FROM Room WHERE Price < 200 AND Types LIKE '@D@'
I guess you were looking for the "AND" keyword.

- 1
- 2
Three things come to mind. First, I haven't seen a product that uses the @ symbol... it is usually the % symbol. Second you do need the AND keyword.
SELECT * FROM Room WHERE (Price < 200) AND (Types LIKE '%D%')
But that leads to the third thing. This query is going to pull anything that has a 'D' anywhere in the types field. If a new type is added later that happens to have a 'D' in the name you are going to suddenly get results you were not expecting. You may want to be more explicit in your condition...
SELECT * FROM Room WHERE (Price < 200) AND (Types LIKE '%Double%')
Obviously if your product really does use the '@' character then substitute it instead. For what its worth, I found this question that lists valid characters for several products and none of the products listed use @.

- 1
- 1

- 3,131
- 1
- 18
- 29