2

I want to search number of strings in the Database (type: MYSQL) and I did this:

SELECT * 
  FROM `rooms` 
 WHERE `dates` LIKE '%09/08/10%' OR '%08/08/10%'

Why doesnt it work? when I removed the part of OR '%08/08/10%' it was working well, I think I use it not good. How should I do it?

OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
Luis
  • 3,257
  • 13
  • 50
  • 59

2 Answers2

5
SELECT ... 
FROM rooms 
WHERE dates LIKE '%09/08/10%' 
  Or dates LIKE '%08/08/10%'
Thomas
  • 63,911
  • 12
  • 95
  • 141
  • There is a simple way than this? Thank you very much! – Luis Aug 03 '10 at 22:58
  • @Luis - As far as I know, there is no simpler means to do a series of wildcard searches. If you wanted an exact match, that would be different. – Thomas Aug 03 '10 at 23:08
  • 2
    You can also try ` WHERE dates REGEXP "0(9|8)/08/10"` (http://dev.mysql.com/doc/refman/5.0/en/regexp.html) – a1ex07 Aug 03 '10 at 23:20
2

Try like this:

SELECT * 
FROM rooms 
WHERE 
      dates LIKE '%09/08/10%' 
      OR 
      dates LIKE '%08/08/10%'
leoinfo
  • 7,860
  • 8
  • 36
  • 48