User Tools

Site Tools


cs:sql_mysql
Site was transfered to www.skenz.it
Please, always refer to this link with the following URL: http://www.skenz.it/cs/sql_mysql

Table of Contents

SQL of MySQL

Example of MySQL queries in the SQL programming languages

SELECT

SELECT *, COUNT(*) as count FROM `users` GROUP BY `users`.`addr` HAVING COUNT(*) > 500

SELECT * `links` FROM `links`, `users` WHERE`links`.`uID`=`users`.`uId` GROUP BY `users`.`addr` HAVING COUNT(*) > 500

SELECT *, COUNT(*) FROM `users` GROUP BY `users`.`addr` HAVING COUNT(*) > 500

SELECT DISTINCT(`field_name`) FROM tableName

DELETE

DELETE `links` FROM `links`, `users` WHERE `users`.`lastAccess` < “2010-12-31” AND `links`.`uId`=`users`.`uId`

DELETE `users` FROM `users` WHERE `users`.`lastAccess` < “2010-12-31”

DELETE `links` FROM `links`, `users`, `ipbanned` WHERE `links`.`uId`=`users`.`uId` AND `ipbanned`.`ip`=`users`.`addr`

DELETE `link` FROM `link`, `user` WHERE `link`.`userId`=`user`.`id` AND `user`.`password`='XXX'

DELETE `user` FROM `user` WHERE `user`.`password`='XXX'

DELETE `users` FROM `users`, `ipbanned` WHERE `ipbanned`.`ip`=`users`.`addr`

DELETE `links` FROM `links` WHERE `links`.`uId` = 0

INSERT

INSERT INTO `ipbanned` (`ip`) SELECT `users`.`addr` FROM `links`, `users` WHERE`links`.`uId`=`users`.`uId` GROUP BY `users`.`addr` HAVING COUNT(*) > 500

INSERT INTO `ipbanned` (`ip`) SELECT `users`.`addr` FROM `users` GROUP BY `users`.`addr` HAVING COUNT(*) > 40


If you found any error, or if you want to partecipate to the editing of this wiki, please contact: wiki [at] altervista.org

You can reuse, distribute or modify the content of this page, but you must cite in any document (or webpage) this url: http://www.skenz.it/cs/sql_mysql
/membri/wiki/data/pages/cs/sql_mysql.txt · Last modified: 2015/10/28 15:22 (external edit)


Policy sui Cookie