{"id":20769,"date":"2014-02-19T16:51:06","date_gmt":"2014-02-19T14:51:06","guid":{"rendered":"https:\/\/mamchenkov.net\/wordpress\/?p=20769"},"modified":"2014-02-19T16:51:59","modified_gmt":"2014-02-19T14:51:59","slug":"the-worst-typo-in-mysql-query-ever","status":"publish","type":"post","link":"https:\/\/mamchenkov.net\/wordpress\/2014\/02\/19\/the-worst-typo-in-mysql-query-ever\/","title":{"rendered":"The worst typo in MySQL query ever"},"content":{"rendered":"<!-- google_ad_section_start -->\n<p>Well, today I&#8217;ve learned something new. \u00a0Typing a query like this:<\/p>\n<pre class=\"brush: sql; light: true; title: ; notranslate\" title=\"\">\r\nUPDATE `table` SET `field` = '1' WHERE `id` = '123'\r\n<\/pre>\n<p>I made a typo and entered the following:<\/p>\n<pre class=\"brush: sql; light: true; title: ; notranslate\" title=\"\">\r\nUPDATE `table` SET `field` = '1' WHERE `id` - '123'\r\n<\/pre>\n<p>Yup. \u00a0A simple dash (-) instead of an equal (=) sign. \u00a0I know, I&#8217;m supposed to do a SELECT before, or use a transaction, or, at least, have a backup of the database &#8211; depending on which school of thought you follow the most. \u00a0I didn&#8217;t have any of these. \u00a0And once the query went in, there was little I could do.<\/p>\n<p>Guess what the query does? \u00a0I&#8217;m still looking into the exact consequences, but so far it looks like <strong>ALL<\/strong> records <strong>EXCEPT<\/strong> the one with id 123 have been updated.<\/p>\n<p>Gladly I have some history revision tables from which I could restore most of the state. \u00a0But this is scary dangerous anyway. \u00a0I would expect a syntax error intuitively.<\/p>\n<!-- google_ad_section_end -->\n","protected":false},"excerpt":{"rendered":"<!-- google_ad_section_start -->\n<p>Well, today I&#8217;ve learned something new. \u00a0Typing a query like this: UPDATE `table` SET `field` = &#8216;1&#8217; WHERE `id` = &#8216;123&#8217; I made a typo and entered the following: UPDATE `table` SET `field` = &#8216;1&#8217; WHERE `id` &#8211; &#8216;123&#8217; Yup. \u00a0A simple dash (-) instead of an equal (=) sign. \u00a0I know, I&#8217;m supposed to &hellip; <a href=\"https:\/\/mamchenkov.net\/wordpress\/2014\/02\/19\/the-worst-typo-in-mysql-query-ever\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">The worst typo in MySQL query ever<\/span><\/a><\/p>\n<!-- google_ad_section_end -->\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_links_to":"","_links_to_target":""},"categories":[1,62],"tags":[1559,3066],"keyring_services":[],"class_list":["post-20769","post","type-post","status-publish","format-standard","hentry","category-general","category-technology","tag-databases","tag-mysql"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":12480,"url":"https:\/\/mamchenkov.net\/wordpress\/2010\/04\/21\/unit-tests-with-cakephp\/","url_meta":{"origin":20769,"position":0},"title":"Unit tests with CakePHP","author":"Leonid Mamchenkov","date":"April 21, 2010","format":false,"excerpt":"I've spent a large part of yesterday setting up the testing environment for a CakePHP project.\u00a0 As always, every time I do something that I have done before, I wanted to do it better, using all the experienced that was acquired previously.\u00a0 And this often leads to the discovery of\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":28562,"url":"https:\/\/mamchenkov.net\/wordpress\/2018\/05\/08\/database-flow-modern-self-hosted-web-interface-for-sql-and-graphql\/","url_meta":{"origin":20769,"position":1},"title":"Database Flow &#8211; modern, self-hosted web interface for SQL and GraphQL","author":"Leonid Mamchenkov","date":"May 8, 2018","format":false,"excerpt":"Database Flow is a modern, Open Source, self-hosted, web-based tool for working with SQL databases and GraphQL APIs.\u00a0 It supports a variety of the database engines: IBM DB2, Oracle, H2, PostgreSQL, MySQL, SQLite, Informix, and Microsoft SQL Server.\u00a0 It features an advanced SQL editor, query plan analyzer, GraphQL client, schema\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2018\/05\/database-flow-500x281.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":14795,"url":"https:\/\/mamchenkov.net\/wordpress\/2011\/04\/27\/mysql-export-csv-into-outfile-triggers-access-denied-error\/","url_meta":{"origin":20769,"position":2},"title":"MySQL export CSV into OUTFILE triggers &#8220;access denied&#8221; error","author":"Leonid Mamchenkov","date":"April 27, 2011","format":false,"excerpt":"I came across a weird problem today. \u00a0Gladly, the web is full of solutions, but I'm going to post this anyway, just to have it nearby for the next time. \u00a0I needed to export the results of some query into a CSV file directly from MySQL. \u00a0I prepared my query,\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":18922,"url":"https:\/\/mamchenkov.net\/wordpress\/2013\/12\/09\/bayesdb-a-bayesian-database-table-for-querying-the-probable-implications-of-data\/","url_meta":{"origin":20769,"position":3},"title":"BayesDB &#8211; a Bayesian database table for querying the probable implications of data","author":"Leonid Mamchenkov","date":"December 9, 2013","format":"link","excerpt":"BayesDB - a Bayesian database table for querying the probable implications of data BayesDB, a Bayesian database, lets users query the probable implications of their data as easily as a SQL database lets them query the data itself. Using the built-in Bayesian Query Language (BQL), users with no statistics training\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10151,"url":"https:\/\/mamchenkov.net\/wordpress\/2006\/05\/31\/daily-del-icio-us-bookmarks\/","url_meta":{"origin":20769,"position":4},"title":"Daily del.icio.us bookmarks","author":"Leonid Mamchenkov","date":"May 31, 2006","format":false,"excerpt":"Shared bookmarks for del.icio.us user tvset on 2006-05-30 MySQL Performance Blog \u00c2\u00bb INSERT ON DUPLICATE KEY UPDATE and summary counters. Tagged as: code databases mysql optimization performance programming sql tips tricks Read\/WriteWeb: Worldwide Internet Penetration is just 15% Tagged as: statistics stats web world","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":28898,"url":"https:\/\/mamchenkov.net\/wordpress\/2018\/10\/29\/soar-sql-optimizer-and-rewriter\/","url_meta":{"origin":20769,"position":5},"title":"SOAR &#8211; SQL Optimizer And Rewriter","author":"Leonid Mamchenkov","date":"October 29, 2018","format":false,"excerpt":"\u00a0 SOAR is an SQL Optimizer and Rewriter.\u00a0 It can help analyse, optimize, and rewrite SQL queries.\u00a0 Don't get offset by the Chinese documentation as default - there is an English translation. Here are some of the features: Cross-platform support, such as Linux, Mac, and Windows Support Heuristic Rules Suggestion\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2018\/10\/soar-1-500x208.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/20769","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/comments?post=20769"}],"version-history":[{"count":0,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/20769\/revisions"}],"wp:attachment":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/media?parent=20769"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/categories?post=20769"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/tags?post=20769"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/keyring_services?post=20769"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}