{"id":73021,"date":"2026-05-13T03:01:00","date_gmt":"2026-05-12T17:01:00","guid":{"rendered":"https:\/\/www.rjmprogramming.com.au\/ITblog\/?p=73021"},"modified":"2026-05-11T11:48:22","modified_gmt":"2026-05-11T01:48:22","slug":"mysql-sql-mindset-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/mysql-sql-mindset-tutorial\/","title":{"rendered":"MySql SQL Mindset Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/MySql\/mysql_sql_mindset.gif\" rel=\"noopener\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"MySql SQL Mindset Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/MySql\/mysql_sql_mindset.gif\" title=\"MySql SQL Mindset Tutorial\"  style=\"float:left;\"   \/><\/a><p class=\"wp-caption-text\">MySql SQL Mindset Tutorial<\/p><\/div>\n<p>We spend a lot of the working time with this blog in a &#8220;what we&#8217;d describe as&#8221; a &#8230;<\/p>\n<blockquote><p>\nJavascript mindset\n<\/p><\/blockquote>\n<p> &#8230; which &#8220;we&#8217;d describe as&#8221; &#8230;<\/p>\n<blockquote><p>\nThis optimistic, and can be chaotic for choice, &#8220;anything&#8217;s possible&#8221;, but is &#8220;syntactically logical&#8221;,  mindset, where Javascript is this &#8220;sponge of the Internet&#8221; not missing out on anything?!  Sound familiar?!  Huh?!\n<\/p><\/blockquote>\n<p>With yesterday&#8217;s <a target=\"_blank\" title='WordPress Same Action Item Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/wordpress-same-action-item-tutorial' rel=\"noopener\">WordPress Same Action Item Tutorial<\/a> though, we got a bit of a lesson bringing that &#8220;Javascript mindset&#8221; into an issue where &#8220;MySql SQL&#8221; was the duck doing all the paddling coming up with a solution to that &#8220;Same Cut to the Chase Action Item&#8221; dropdown idea.<\/p>\n<p>We found out, probably four hours later &#8230;<\/p>\n<blockquote><p>\nRegarding MySql SQL work <font size=1>(which we debug and &#8220;live in&#8221; the <sup>great<\/sup> <sub>incredible<\/sub> <sup>stupendous<\/sup> <a target=\"_blank\" title='phpMyAdmin administrator for MySql database' href='https:\/\/www.phpmyadmin.net\/' rel=\"noopener\"><i>phpMyAdmin<\/i><\/a> environment wooooorrrrlllllldddd regarding)<\/font> just because an SQL statement looks &#8220;syntactically logical&#8221; does not always guarantee success.\n<\/p><\/blockquote>\n<p>Take a look at &#8230;<\/p>\n<table style=width:100%;>\n<tr>\n<th>What did not work<\/th>\n<th>Error Message<\/th>\n<\/tr>\n<tr>\n<td style=vertical-align:top;>\n<code style=\"word-break:break-all;\"><br \/>\nSELECT wps_posts.post_title, wps_posts.guid, wps_posts.post_content, LOCATE('\/PHP\/animegif\/tutorial_to_animated_gif.php',wps_posts.post_content) as tfind, LOCATE('\/PHP\/animegif\/tutorial_to_animated_gif.php',wps_posts.post_title) as tother, wps_posts.post_date as post_date FROM wps_posts<br \/>\nWHERE wps_posts.post_status = 'publish'<br \/>\nAND <font color=red>(1 = 11 OR LOWER(wps_posts.post_title) = LOWER('\/PHP\/animegif\/tutorial_to_animated_gif.php'))<br \/>\nAND (wps_posts.post_content like CONCAT(CONCAT('%?p=',wps_posts.guid), '%')<br \/>\nOR <\/font>SUBSTRING(wps_posts.post_content,1,240) like '%\/PHP\/animegif\/tutorial_to_animated_gif.php\"%'<font color=red>)<\/font>  UNION SELECT 'Code Download Table' as post_title, wps_posts.post_content as guid, '' as post_content, 1 as tfind, 0 as tother, CURTIME() as post_date FROM wps_posts<br \/>\nWHERE wps_posts.post_status = 'publish'<br \/>\nAND LOWER(wps_posts.post_title) = LOWER('\/PHP\/animegif\/tutorial_to_animated_gif.php')<br \/>\nAND wps_posts.post_content like '%GETME%' ORDER BY post_date<br \/>\n<\/code>\n<\/td>\n<td style=vertical-align:top;>\n<font color=red>MySQL returned an empty result set (ie. zero rows). (Query took 5.8648 seconds).<\/font>\n<\/td>\n<\/tr>\n<tr>\n<th colspan=2>Versus what did work<\/th>\n<\/tr>\n<tr>\n<td colspan=2>\n<code style=\"word-break:break-all;\"><br \/>\nSELECT wps_posts.post_title, wps_posts.guid, wps_posts.post_content, LOCATE('\/PHP\/animegif\/tutorial_to_animated_gif.php',wps_posts.post_content) as tfind, LOCATE('\/PHP\/animegif\/tutorial_to_animated_gif.php',wps_posts.post_title) as tother, wps_posts.post_date as post_date FROM wps_posts<br \/>\nWHERE wps_posts.post_status = 'publish'<br \/>\nAND SUBSTRING(wps_posts.post_content,1,240) like '%\/PHP\/animegif\/tutorial_to_animated_gif.php\"%'  UNION SELECT 'Code Download Table' as post_title, wps_posts.post_content as guid, '' as post_content, 1 as tfind, 0 as tother, CURTIME() as post_date FROM wps_posts<br \/>\nWHERE wps_posts.post_status = 'publish'<br \/>\nAND LOWER(wps_posts.post_title) = LOWER('\/PHP\/animegif\/tutorial_to_animated_gif.php')<br \/>\nAND wps_posts.post_content like '%GETME%' ORDER BY post_date<br \/>\n<\/code>\n<\/td>\n<\/tr>\n<\/table>\n<p> &#8230; as a case in point?!  We tried <a target=\"_blank\" href='https:\/\/www.google.com\/search?q=can+mysql+sql+return+zero+rows+just+because+of+the+overly+complex+where+clause%3F&#038;rlz=1C5OZZY_en&#038;oq=can+mysql+sql+return+zero+rows+just+because+of+the+overly+complex+where+clause%3F&#038;gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIHCAEQIRiPAjIHCAIQIRiPAtIBCTMxNDkwajBqN6gCALACAA&#038;sourceid=chrome&#038;ie=UTF-8' rel=\"noopener\">this ask (can mysql sql return zero rows just because of the overly complex where clause?)<\/a> of Google to try to find out why, regarding &#8220;relative database&#8221; mindsets this <a target=\"_blank\" title='MySql SQL ask' href='https:\/\/www.google.com\/search?q=can+mysql+sql+return+zero+rows+just+because+of+the+overly+complex+where+clause%3F&#038;rlz=1C5OZZY_en&#038;oq=can+mysql+sql+return+zero+rows+just+because+of+the+overly+complex+where+clause%3F&#038;gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIHCAEQIRiPAjIHCAIQIRiPAtIBCTMxNDkwajBqN6gCALACAA&#038;sourceid=chrome&#038;ie=UTF-8' rel=\"noopener\">might be so<\/a> &#8230;<\/p>\n<blockquote cite='https:\/\/www.google.com\/search?q=can+mysql+sql+return+zero+rows+just+because+of+the+overly+complex+where+clause%3F&#038;rlz=1C5OZZY_en&#038;oq=can+mysql+sql+return+zero+rows+just+because+of+the+overly+complex+where+clause%3F&#038;gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIHCAEQIRiPAjIHCAIQIRiPAtIBCTMxNDkwajBqN6gCALACAA&#038;sourceid=chrome&#038;ie=UTF-8'><p>\n<a target=\"_blank\" title=\"?\" href='https:\/\/stackoverflow.com\/questions\/46049329\/mysql-select-query-does-not-return-results-when-using-a-where-clause-against-a-n' rel=\"noopener\">Yes<\/a>, a complex WHERE clause in MySQL can cause a query to return zero rows if it inadvertently filters out all data. This often happens due to logical errors, such as conflicting conditions, NULL values treated as equal to other values, or using NOT IN with subqueries that include NULL.\n<\/p><\/blockquote>\n<p>Interesting, huh?!<\/p>\n<p>Perhaps the <a target=\"_blank\" title='Keep It Simple, Stupid' href='https:\/\/www.google.com\/search?q=KISS+principle&#038;sca_esv=af156264804c4707&#038;rlz=1C5OZZY_en&#038;sxsrf=ANbL-n5D8Lpx88WpOyRaulpCeN-wF70tUg%3A1778461964995&#038;ei=DC0Bau29PNudseMPu6aGqQU&#038;biw=1320&#038;bih=741&#038;ved=0ahUKEwjt862Nh7CUAxXbTmwGHTuTIVUQ4dUDCBE&#038;uact=5&#038;oq=KISS+principle&#038;gs_lp=Egxnd3Mtd2l6LXNlcnAiDktJU1MgcHJpbmNpcGxlMgUQABiABDIFEAAYgAQyBRAAGIAEMgUQABiABDILEAAYgAQYigUYkQIyBRAAGIAEMgUQABiABDIFEAAYgAQyBRAAGIAEMgUQABiABEjDI1AAWI8icAB4AJABAJgBtgGgAcgRqgEEMC4xNLgBA8gBAPgBAZgCDqACvxLCAgoQIxiABBiKBRgnwgIEECMYJ8ICERAuGIAEGLEDGIMBGMcBGNEDwgIOEAAYgAQYigUYsQMYgwHCAg4QLhiDARixAxiABBiKBcICDhAuGIAEGLEDGMcBGNEDwgILEAAYgAQYsQMYgwHCAgsQLhiABBiKBRiRAsICERAuGIAEGIoFGJECGMcBGK8BwgIKEC4YgAQYigUYQ8ICChAAGIAEGIoFGEPCAhAQABiABBiKBRhDGLEDGIMBwgITEC4YgAQYigUYQxixAxjHARjRA8ICCxAuGIAEGLEDGIMBwgIOEC4YgAQYigUYsQMYgwHCAggQABiABBixA8ICGhAuGIAEGIoFGJECGJcFGNwEGN4EGOAE2AEBwgINEC4YgAQYigUYQxixA8ICDRAAGIAEGIoFGEMYsQPCAhAQLhiABBiKBRhDGLEDGIMBwgIgEC4YgAQYigUYkQIYxwEYrwEYlwUY3AQY3gQY4ATYAQHCAgUQLhiABMICCxAuGIAEGMcBGK8BmAMAugYGCAEQARgUkgcEMC4xNKAH2r0BsgcEMC4xNLgHvxLCBwYyLTEyLjLIB1WACAE&#038;sclient=gws-wiz-serp' rel=\"noopener\">KISS<\/a> principle should apply here, especially if you are doing MySql SQL outside the original <i>index<\/i><sup>ing<\/sup> database design thoughts <font size=1>( as we were needing to use here with the MySql SQL function <a target=\"_blank\" title='MySql SQL SUBSTRING function' href='https:\/\/www.w3schools.com\/sql\/func_mysql_substring.asp' rel=\"noopener\">SUBSTRING<\/a> )<\/font>.  Also, if we&#8217;re into the &#8220;blame game&#8221; here, question whether a solution you are achieving is inefficient, and wasteful, before applying it as your final offering!<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d73021' onclick='var dv=document.getElementById(\"d73021\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/sql\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d73021' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>We spend a lot of the working time with this blog in a &#8220;what we&#8217;d describe as&#8221; a &#8230; Javascript mindset &#8230; which &#8220;we&#8217;d describe as&#8221; &#8230; This optimistic, and can be chaotic for choice, &#8220;anything&#8217;s possible&#8221;, but is &#8220;syntactically &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/mysql-sql-mindset-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,12,37],"tags":[2774,299,5503,604,5502,5500,3373,5498,827,932,938,997,1018,5501,1186,5499,2386,1319,4619],"class_list":["post-73021","post","type-post","status-publish","format-standard","hentry","category-database","category-elearning","category-tutorials","tag-clause","tag-database-2","tag-database-design","tag-index","tag-indexing","tag-kiss","tag-logic","tag-logical","tag-mysql","tag-php","tag-phpmyadmin","tag-programming","tag-query","tag-relative-database","tag-sql","tag-statement","tag-syntax","tag-tutorial","tag-where-clause"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/73021"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=73021"}],"version-history":[{"count":12,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/73021\/revisions"}],"predecessor-version":[{"id":73039,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/73021\/revisions\/73039"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=73021"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=73021"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=73021"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}