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
  • 314,254
  • 77
  • 507
  • 490
Luis
  • 3,089
  • 12
  • 46
  • 58

2 Answers2

5
SELECT ... 
FROM rooms 
WHERE dates LIKE '%09/08/10%' 
  Or dates LIKE '%08/08/10%'
Thomas
  • 62,492
  • 11
  • 93
  • 137
  • 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,602
  • 8
  • 34
  • 47