select DISTINCT (tool_sub_type) from table where tool_type = 1 ;
三表联查(and)
select * from table_1 t1 ,table_2 t2,table_3 t3
where t1.store_id = t2.id and t2.company_id=t3.id;
三表联查(left join)
select* from table_1 t1
LEFT JOIN table_2 t2 on t1.store_id = t2.id
LEFT JOIN table_3 t3 on t2.company_id = t3.id
从a表迁移部分数据到b表
update t_a a set
a.seller_id =(select seller_id from customer_file b where b.id=a.customer_id ),
a.seller_name =(select name from customer_file b where b.id=a.customer_id ),
a.gmt_modified =now();
更新语句:
update table SET tool_sub_type =9 where id = 2;
插入语句
insert into table(gmt_create,gmt_modified,parent_id,sub_name) value(now(),now(),1,"子类目");
不为空SQL IS NOT NULL
选取在 "Address" 列中不带有 NULL 值的记录呢?
SELECT LastName,FirstName,Address FROM Persons
WHERE Address IS NOT NULL