mysql语句
查询字段长度:
SELECT MAX(LENGTH(pd)) FROM `table` where id=2;
来检查当前表中字段的字符集设置。
show full fields from tableName;
1、字段使用别名:
Select remark as r from ‘test’
2、Select * from ‘test’ where id in (1,2,4)
3、select * from ‘test’ where id=2
4、select * from ‘test’ where ‘uid’ like ‘%王%’
5、select * from ‘test’ where id between 1 and 3
6、select * from ‘test’ id=1 and ‘remark’=’学生’
-------------------------------------------------------------------------------------------
7、select * from ‘test’ group by ‘remark’
8、select * from ‘test’ order by ‘regdate’ desc 降序
9、group by ->order by ->limit
--------------------------------------------------------------------------------------------
10、Select count(*) from ‘test’ where 1
11、Select MAX(id) from ‘test’
12、Select MIN(id) from ‘test’
13、select avg(年龄) as 平均年龄 from student group by 性别;
14、Insert into test(‘id’,’uid’,’regdate’,’remark’) values (‘ ’,’PHP100’,now(),’工人’)
15、Insert into test values(‘ ’,’PHP100’,now(),’工人’)
16、update test set uid=’PHP300’ where id=6
17、delete from test where id=3