Left和date_format函数:
[code]
$sql="select count(*) from Tbl_XXshow_XX where  FXX='$XX' and FCode=2 and left(FTime,7)=left(now(),7)";
select count(*) as c from Tbl_Exchange_XX where FLType=218 and date_format(now(),'%Y-%m-%d')=date_format(FTime,'%Y-%m-%d')
[/code]
在mysql中涉及到编码是最让人头疼的。
编写update.txt (注意:utf8的编码要存为utf8的txt格式,当然你也可以命名后缀改为:update.sql etc)
source的sql包含中文(位置在/root/update.txt):
update Tbl_User set FAddr="四川内江东兴区平安路148号E栋8号" where FQQ="348813422";


mysql> use DB_****_2nd;
Database changed
mysql> source /root/update.txt
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0


然后,发现php程序读出来发现是乱码。
查看mysql编码:
mysql> show variables like '%char%';

mysql> show variables like '%char%';
+--------------------------+----------------------------------------------------------------------+
| Variable_name            | Value                                                                |
+--------------------------+----------------------------------------------------------------------+
| character_set_client     | utf8                                                                 |
| character_set_connection | utf8                                                                 |
| character_set_database   | utf8                                                                 |
| character_set_filesystem | binary                                                               |
| character_set_results    | utf8                                                                 |
| character_set_server     | latin1                                                               |
| character_set_system     | utf8                                                                 |
| character_sets_dir       | /usr/local/mysql-max-5.0.27-linux-i686-glibc23/share/mysql/charsets/ |
+--------------------------+----------------------------------------------------------------------+
8 rows in set (0.00 sec)


原来是:
| character_set_server     | latin1                                                               |
不是utf-8:
于是:需要,set names 'utf8';


mysql> set names "utf8";
Query OK, 0 rows affected (0.00 sec)

mysql> source /root/update.txt
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0

mysql>


在php中显示中文正常,哈哈哈!
分页: 5/5 第一页 上页 1 2 3 4 5 最后页 [ 显示模式: 摘要 | 列表 ]