User Tools

Site Tools


cs:sql_mysql
Return to Home page

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: admin [at] skenz.it

You can reuse, distribute or modify the content of this page, but you must cite in any document (or webpage) this url: https://www.skenz.it/cs/sql_mysql
/web/htdocs/www.skenz.it/home/data/pages/cs/sql_mysql.txt · Last modified: 2024/04/08 22:35 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki
Privacy Policy