数据库与表操作

显示数据库:

show databases;

切换数据库:

use  theDatabase

显示当前数据库的所有表

show tables

展示表属性:

show create table theTable

查询数据库的记录条数:



select count(*) as total from theTable


mysq中的时间向前移一天:



update theTable set create_time=create_time-86400 where id=566


mysql将查询的时间错发转换为时间:



select uid,nickname,from_unixtime(create_time) from theTable where nickname="lyh";


单个字段的查询与操作

Mysql替换某个字段中的字符串:



updat 表名 set 字段名=replace(字段名,'原来的内容','替换后的内容')
update wp_posts set post_content = replace(post_content,'39.105.62.250/fityoo/','www.fityoo.cn/');


Mysql查询某个字段包含某个内容:



select post_content from wp_posts where post_content like '%365天%';


多表连接查询

3表连接查询:



select t1.*,
t2.category_name,
t3.org_section_name
from devices as t1
left join first_category as t2 on t1.first_category_id = t2.id
left join org_section as t3 on t1.org_section_id = t3.id


 


博客里大都是转载的内容,其目的主要用户知识的组织和管理。