摘要: substr函数可以从一个字符串中提取其中的一部分,它使用三个参数:字符串,开始位置,以及要检索的字符个数 string substr(string striting, int start [, int lengtn]) 如果start的位置为正值,提取将从字符串的第一个字符开始,但是如果start的位置为负值,提取字符串的开始位置从字符串的尾部开始计算 $extract = substr(... 阅读全文
posted @ 2013-11-28 03:34 long896130895 阅读(5111) 评论(0) 推荐(0)
摘要: 如果以数字开头的字符串和数字运算 $a=’25 nihao’ +32 echo $a; 输出的是57 如果数字加在中间$b=’nihao23’+56 echo $b;得到的是nihao2356 阅读全文
posted @ 2013-11-28 03:13 long896130895 阅读(133) 评论(0) 推荐(0)
摘要: 设置客户端的编码 set character_set_client=gbk 设置连接器编码 set character_set_connection=gbk 设置返回值编码 set character_set_results=gbk 如果client(客户端)、connection(连接器)、results(返回值)都设置成gbk的话,可以简写成 set names... 阅读全文
posted @ 2013-11-28 00:46 long896130895 阅读(2451) 评论(0) 推荐(0)
摘要: view 可以看做一张虚拟表,是通过某种运算得到的一个投影 视图不需要指定视图的列名或者列类型,因为它只是一个影子,继承了上面的关系 查询的结果命名为视图 语法 create view 视图名 as select 语句 create view pjasselect goods_name,shop_price from goods order by shop_price;视图创... 阅读全文
posted @ 2013-11-27 16:14 long896130895 阅读(138) 评论(0) 推荐(0)
摘要: 从表中删除数据使用delete,从表中删除特定的行,或者所有行 delete from customers 删除哪一表中where cust_id =1006; 哪一列一定要注意,update后面是没有from的,直接跟表名,而 delete后面有from 然后再跟表名更新表 alter table vendors 更新表 表名add ven... 阅读全文
posted @ 2013-11-27 03:18 long896130895 阅读(121) 评论(0) 推荐(0)
摘要: 1要更新的表 2列名和他们的新值 3确定要更新运行的条件 update customers 要更新的表名set cust_email='123@qq.com' 赋新值where cust_id = 1005; 执行条件,更新哪一行ignore关键字如果用update语句更新多行,并且在更新这些行中的一行或者多行发生一个错误,则整个update操... 阅读全文
posted @ 2013-11-27 03:14 long896130895 阅读(129) 评论(0) 推荐(0)
摘要: insert 一般用来给表插入一个指定列值的行,但是insert还存在另外一种形式,可以利用它将一条select语句的结果插入到表中,这就是所谓的insert select ,顾名思义,它是由一条insert语句和一条select语句组合成的 insert into customers ( cust_id, cust_name)select cust_id, cust_name... 阅读全文
posted @ 2013-11-27 03:04 long896130895 阅读(339) 评论(0) 推荐(0)
摘要: 组合查询通常称为并(union)或者复合查询(compound query) union的每个查询必须包含相同的列,表达式或者聚集函数(不过各个列不需要以相同的次序列出) 使用union all 返回所有行,重复的不再隐藏 阅读全文
posted @ 2013-11-27 02:40 long896130895 阅读(175) 评论(0) 推荐(0)
摘要: select cust_name,cust_contactfrom customers as c,orders as o,orderitems as oiwhere c.cust_id = o.cust_id and oi.order_num = o.order_num and prod_id = 'tnt2';上语句中 customers as c 建立c作为customers的别名... 阅读全文
posted @ 2013-11-27 01:30 long896130895 阅读(255) 评论(0) 推荐(0)
摘要: select vend_name,prod_name,prod_price from vendors,productswhere vendors.vend_id=products.vend_idorder by vend_name,prod_name;内部联结 select vend_name,prod_name,prod_price from vendors inner join pro... 阅读全文
posted @ 2013-11-27 00:42 long896130895 阅读(139) 评论(0) 推荐(0)