mysql更新数据限制limit
mysql更新时,要更新记录中某个区间的数据,只能用WHERE条件来限制了,
用LIMIT只能限制更新多少条!测试如下:
UPDATE products SET goods_number = goods_number+10 ORDER BY goods_id DESC LIMIT 5,10
上面这句测试了是错误的,MYSQL的UPDATE语句不能更新限制从第几条到第几条!
错误提示:#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '10' at line 1
只能用下面这样的语句了,要么你就用where条件语句来限制了
UPDATE products SET goods_number = goods_number+10 ORDER BY goods_id DESC LIMIT 10
mysql查询默认是不区分大小写的 如:
1. select * from table_name where a like 'a%'
2. select * from table_name where a like 'A%'
效果是一样的。
要让mysql查询区分大小写,可以:
1. select * from table_name where binary a like 'a%'
2. select * from table_name where binary a like 'A%'
也可以在建表时,加以标识
1. create table table_name(
2. a varchar (20) binary
3. )
MySQL表别名、字段别名注意事项
字段别名:可加 as ,也可以不加,可以加单|双引号,也可以不加;
表别名:可加 as ,也可以不加,但是一定不能加单|双引号!