User Tools

Site Tools


cs:sql_mysql
Return to Home page

Differences

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

Link to this comparison view

cs:sql_mysql [2019/02/26 14:33] (current)
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?rev=1551188037&do=diff
/web/htdocs/www.skenz.it/home/data/pages/cs/sql_mysql.txt ยท Last modified: 2019/02/26 14:33 (external edit)

Privacy Policy