首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

MySQL第二课

2012-11-01 
MySQL第二课!?今天将mysql第二课,主要讲了增删改和查的一部分。?增:INSERT INTO t_user? ? ? ? ? ? ? ? (`n

MySQL第二课!

?今天将mysql第二课,主要讲了增删改和查的一部分。

?增:

INSERT INTO t_user

? ? ? ? ? ? ? ? (`name`,address,personcode)

VALUES ? ?('jack',DEFAULT,'010'),

? ? ? ? ? ? ? ? ('alex','China','009'),

? ? ? ? ? ? ? ? ('lilei','Kr','011');

改:UPDATE t_user SET address = '缅甸',`name`='Park' ?WHERE id =8;

删:DELETE FROM t_user WHERE id = 4;

? ? ?TRUNCATE TABLE t_person; ?//见表中的内容全部删除

?

查: ? ? ?SELECT DISTINCT id FROM products; ? ? ??/*去除重复列*/ ?

SELECT name,zip FROM vendors LIMIT 4,2; ? ? ? ? ?//显示查询记录的第五和第六条,4代表起始行,2代表显示几行

select * from t_stu order by score desc; ? ? ? ? ?//desc表示降序,默认为asc,表示升序

select * from t_stu where email is null; ? ? ? ? ? //显示t_stu 表中email为空的记录 ? [is not null]

select * from t_stu? where id in(100,1002); ? ? ? ?//显示t_stu表中id是100或1002的记录

select * from t_stu? where name like '%f%'; ? ? ? ?// 表示t_stu表中name里含有f的记录

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //'_'表示匹配一个字符 ?'%'表示匹配一个或多个字符

?

SELECT CONCAT('This is ',cust_name) AS `name` FROM customers; ?//表示新建一个列名为name的新列,内容为'This is '+cust_name

热点排行