在mysql中“喜欢”

I have written a simple mysql search form that searches between two dates. This query working perfect:

$sql = "SELECT * FROM table WHERE  dateStarted like '%$checkin%' 
AND dateEnded like '%$checkout%'";

But with

$sql2 = "SELECT * FROM table WHERE  dateStarted = $checkin 
AND dateEnded = $checkout";

There is no any result? What is difference between two sql?

Edit:

$checkin and $checkout are date (16-07-2010) 

Thanks in advance

$checkin and $checkout are date (16-07-2010)

Try putting quotes in your query:

$sql2 = "SELECT * FROM table WHERE  dateStarted = '$checkin'
         AND dateEnded = '$checkout'";

One matches the value of the variable $checkin, the other matches anything containing the value of the variable $checkin.

So if $checkin is foo, then the first will match "foo" or "something foosomething" while the second will match only "foo".

"like" is for text and "=" for numbers and so on