mysql 随笔

  • blob类型数据

blob类型可存储文本、富文本、html,正常查询、更新不会显示内容,需要转换:

SELECT *,CAST(字段名 AS char) FROM table;  #存储类型为文本时,使用char

SELECT *,convert(content USING utf8) as tx from table; 

 

  • mysql 不能使用别名作为where条件

如上面使用  SELECT *,convert(content USING utf8) as tx from table where tx='text';

会报错,因为where语句执行在先;但可在 GROUP BY, ORDER BY, HAVING 引用

 

  • mysql中sql语句执行顺序

1. from
2. on
3. join
4. where
5. group by
6. with
7. having
8. select
9. distinct
10. order by
11. limit

中间的每一步都会生成一张虚拟表,后面的步骤都是在上一张虚拟表中进行筛选与查询的

posted @ 2021-08-31 16:46  TGZZ  阅读(49)  评论(0)    收藏  举报