您好,欢迎访问一九零五行业门户网

mysql:最实用的sql语句_MySQL

bitscn.com
mysql:最实用的sql语句
1.把catalog_product_entity_text表字段里面的导入:c:/mysql/bin/> mysql -u root -p 说明:c:/mysql/bin/表示进入mysql程序根目录
c:/helloapp/schema/sampledb.sql是要导入数据库的文件的位置
c:/mysql.sql是导出的sql文件
--default-character-set=utf8 指编码方式
7.建新表
create table if not exists `isc_pluginproduct_association` (
  `id` int(11) not null auto_increment,
  `main_cat_id` int(11) not null,
  `product_id` int(11) not null,
  primary key (`id`)
) engine=myisam  default charset=latin1 auto_increment=66 ;
insert into `isc_pluginproduct_association` (`id`, `main_cat_id`, `product_id`) values
(65, 31, 24),
(64, 31, 18),
(63, 31, 23),
(62, 32, 24),
(61, 32, 23),
(60, 32, 28),
(51, 38, 26),
(16, 36, 14),
(15, 36, 15),
(50, 38, 23),
(49, 38, 22),
(48, 38, 21),
(47, 38, 20),
(46, 38, 18),
(45, 38, 16),
(44, 38, 12),
(43, 38, 10),
(42, 38, 15),
(41, 38, 17),
(40, 38, 13),
(57, 39, 16),
(56, 39, 15),
(55, 39, 14);
8.多个and条件的查询语句
(1)myphp的sql语句:
select * 
from  `isc_products` 
where  `prodcode` =  'ip-z0144'
and  `prodname` like  '%tilt wifi %'
and  `prodprice` = 144.00
limit 0 , 30
9.把产品名字中的特殊符号和空格替换为-号,查找产品
select * from `isc_products` where 
`prodname` like '%5%'
and `prodname` like '%megapixels%'
and `prodname` like '%1%'
and `prodname` like '%2.5%'
and `prodname` like '%sensor%'
and `prodname` like '%720p%'
and `prodname` like '%outdoor%'
and `prodname` like '%ip%'
and `prodname` like '%camera%'
and `prodname` like '%40m%'
and `prodname` like '%ir%'
and `prodname` like '%night%'
and `prodname` like '%view%'
10.写一个数据库的语句:将a表里,b字段中第一个c字符替换成d
(1) 查询`isc_search_corrections`表的`correction`字段的首字母
select substring(`correction`,1,2) from `isc_search_corrections`
(2) 更新:`isc_search_corrections`表,`correction`字段含有首字母c的替换首字母为d
update `isc_search_corrections` set `correction` = replace(`correction`, 'c', 'd') where  substring(`correction`,1,2)='c'
bitscn.com
其它类似信息

推荐信息