User Tools

Site Tools


cs:sql_mysql
Return to Home page
no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


cs:sql_mysql [2024/04/08 22:35] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
 +====== 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?do=diff&rev2%5B0%5D=&rev2%5B1%5D=1551188037&difftype=sidebyside
/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