mysql:最适用的sql语句

mysql:最适用的sql语句

mysql:最实用的sql语句


1.把catalog_product_entity_text表字段里面的<a href=”mailto:替换为<a rel=”nofollow”  href=”mailto:


UPDATE `catalog_product_entity_text` SET `value` = REPLACE(`value`, ‘<a href=”mailto:’, ‘<a rel=”nofollow” href=”mailto:’) WHERE INSTR(`value`,'<a href=”mailto:’) > 0 

2.给表添加一个列


ALTER TABLE `isc_product_tags`  ADD `bigtags`  VARCHAR(20) 

(1)删除多余的行数
delete FROM `isc_product_tags` WHERE `tagname`=”

3.删除表的数据
TRUNCATE TABLE `directory_country`

4.关联查找tags表里的tags的相关的其他tags:

(1)查找tags表里的tags的相关的其他tags:
SELECT * FROM `isc_product_tags` WHERE `bigtags`=(SELECT `bigtags` FROM `isc_product_tags`  WHERE `tagfriendlyname`=’720p-car-dvr’) and `tagfriendlyname` !=  ‘720p-car-dvr’ ORDER BY  ‘tagname’ DESC;

(2)查找某个产品的所有关联tags:
SELECT * FROM `isc_product_tags` WHERE `tagid`in(SELECT `tagid` FROM  `isc_product_tagassociations` WHERE `productid`=(SELECT `productid` FROM `isc_products` WHERE `prodname`=’Mega Pixel 720p HD IR Array Waterproof Network TF Storage Camera’))

SELECT * FROM `isc_product_tags` WHERE `tagid` in(SELECT `tagid` FROM  `isc_product_tagassociations` WHERE `productid`=(SELECT `productid` FROM `isc_products`  WHERE `prodname`=’5 Megapixel Sensor Full HD 1080P Outdoor IP Camera 120m IR Night View ‘))  ORDER BY tagname ASC

5.更改产品价格:
UPDATE`isc_products` SET `prodretailprice` = ‘92.0000’, `prodsaleprice`=’69.0000′ WHERE  `productid` =1605;


6.导入导出数据库命令:(bin目录下)


导出:mysqldump -u root -p bokele >c:/mysql.sql –default-character-set=utf8


导入:C:mysqlbin> mysql -u root -p <C:helloappschemasampledb.sql –default-character-set=utf8 


说明:C:mysqlbin表示进入mysql程序根目录

C:helloappschemasampledb.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),


<span style="font-size

mysql:最适用的sql语句

相关文章:

你感兴趣的文章:

标签云: