In the Friday, to do a PHP simultaneously to the MySQL database and SQL Server database connection Dongdong
I used to use MySQL to be not very familiar with SQL Server, so stones. No, at least MySQL and SQL Server are relatives.
When you make a conditional query. There is a problem
The first is that the query time is this format
10:20:20am
I open the SQL Server database to view the data in the table
It was 2009-11-30 10:20:20.233.
Later looked like SQL Server has a format problem, but the output of the time to want is 2009-11-01, there is no way, only after the query out the data after the conversion of a
Under MySQL.
For example, I want to find data for time periods from 2009-11-01 to 2009-11-30.
SELECT * FROM table where time > ' 2009-11-01 ' and Time < ' 2009-11-30 ';
I drew a tiger, and I had no idea where I was going, and I didn't have any effect.
I think my 2009-11-01 is really bad compared with one of the 10:20:20am or 2009-11-30 10:20:20.233, at least comparable
So I converted my 2009-11-01 to 00:00:00am and 2009-11-01 00:00:00.000
No more than one. In the ":" Error. It's not uncomfortable!
So uncomfortable looking for a day also did not point suddenly small enlightenment, not because of this small problem, affect my image bar, today, early morning woke up,
Yesterday I found the time conversion function of SQL Server convert includes many kinds, that is, no 2009-11-01 this format, do not know whether I am stupid or stupid
There is no way, only a medium and a bit, first convert 2009-11-01 to 20091101 and then the 10:20:20am or 2009-11-30 10:20:20.233 converted into 20091130 and then compare,
Don't say it, it's a real result.
SELECT * FROM table where convert (varchar (ten), date_time,112)!< $begin _date and CONVERT (varchar), date_time,112)!& Gt $end _date
(!< and!> also almost tripped me)
http://www.bkjia.com/PHPjc/321001.html www.bkjia.com true http://www.bkjia.com/PHPjc/321001.html techarticle In Friday, to do a PHP simultaneously to the MySQL database and SQL Server database connection east has been using MySQL is not very familiar with SQL Server, so stones. Nothing else to ...