mysql遇见问题(集)

此文章作为 mysql 问题记录:

1. select * from `Passport` where `PassportID`={$passportID}

遭遇问题的就是这样一条语句 ,咋一看没错,但是问题就出在where之前的空格上,因为在coding与同事交流,手误输入了全角空格,导致语法错误

2. php 代码: $sql = "select * from `Passport` where unix_timestamp({$date_start})>unix_timestamp({$date_end})";

上面的语句中,日期没有引号引起, 并不会报错。 在mysql中 unix_timestamp(2012-12-12) 返回的值为0

3. MySQL Server Error: mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file ( 2000 )

4.

1093 - You can't specify target table 'ordercw' for update in FROM clause 

不能对一张表中的数据 , 查询出来更新或删除

处理的方法是使用, 创建临时表 , 然后在进行处理

create table 临时表 as select XXX as XXXOther from 原先表;
delete from 原先表 where id  in (select XXXOther   from 临时表); 
drop table 零时表;

 

5. 根据条件导出数据库中某种表中数据

mysqldump -u root -p database --no-create-db=TRUE --no-create-info=TRUE --add-drop-table=FALSE --where="XXX" table>file_path;

你可能感兴趣的:(mysql,mysql常见问题)