{"id":5558,"date":"2024-01-26T18:51:04","date_gmt":"2024-01-26T18:51:04","guid":{"rendered":"https:\/\/balldiamondball.com\/blog\/?p=5558"},"modified":"2024-01-26T19:45:00","modified_gmt":"2024-01-26T19:45:00","slug":"some-horrific-sql","status":"publish","type":"post","link":"https:\/\/balldiamondball.com\/blog\/some-horrific-sql\/","title":{"rendered":"Some Horrific SQL"},"content":{"rendered":"<p>Yeah yeah, don&#8217;t carp to me about SQL.\u00a0 I&#8217;ll have you know that the language is mathematically derived, and is <em>the correct way<\/em> to deal with data.\u00a0 God Bless all those elementary school teachers who tried to impress upon us the importance of the intersection of the set of all apples and the set of all thing that Johnny possessed, as they were on to someting, but they didn&#8217;t understand it any more than we did, and it showed.\u00a0 They had the teachers&#8217; edition and we did not, and that was that.<\/p>\n<p>That nonsense of apples and Johnnies is a problem which still plagues database instruction to this day.\u00a0 Do you know the name Alfreds Futterkiste?\u00a0 I&#8217;ll stab that bastard if I ever see him.\u00a0 I recently saw an example describing how one might wish to filter a sharepoint list combining criteria with some AND and OR operators.\u00a0 Well and good, but the filters they combined were &#8220;class = mammal&#8221; AND (&#8220;species = cat&#8221; OR &#8220;species = dog&#8221;).\u00a0 This is patently stupid &#8212; every dog and\/or cat is a mammal, so there is no need to filter on class here, like Sillitoe.\u00a0 And so it goes, where fruits and mammals and occasionally make\/model\/year are trotted out as stultifyingly inappropriate examples to teach us how to use SQL.<\/p>\n<p>So it&#8217;s no wonder that I churn out highly successful but <em>appallingly bad<\/em> SQL such as the following, trying to identify remaining lumps in my quest to sift the junk users up outta here:<\/p>\n<pre>SELECT \r\nSUBSTRING(user_email, LOCATE('@', user_email) + 1) \r\n\u00a0\u00a0 AS da_domain, \r\n\r\nREVERSE(SUBSTRING(user_email, LOCATE('@', user_email) + 1)) \r\n\u00a0\u00a0 AS da_reverse,\r\n\r\nREVERSE(SUBSTRING(REVERSE(SUBSTRING(user_email, LOCATE('@', user_email) + 1)), \r\n   LOCATE('.', REVERSE(SUBSTRING(user_email, LOCATE('@', user_email) + 1))) + 1)) \r\n\u00a0\u00a0 AS da_domainlocal,\r\n\r\nREVERSE(SUBSTRING(REVERSE(SUBSTRING(user_email, LOCATE('@', user_email) + 1)),1, \r\n   LOCATE('.', REVERSE(SUBSTRING(user_email, LOCATE('@', user_email) + 1))) - 1)) \r\n\u00a0\u00a0 AS da_domaintop,\r\n\r\ncount(*)\r\n\r\nFROM wp_users \r\nGROUP BY da_domainlocal\r\nORDER BY COUNT(*) DESC \r\nLIMIT 1000;<\/pre>\n<p>What we are doing here:<\/p>\n<p>TAKE the email address of a user:\u00a0 ev.il.sp.am.mer.84383@morons.stupidmail.com.<\/p>\n<p>SPLIT it at the &#8216;@&#8217; symbol and take the latter portion, which is the domain, called here &#8216;da_domain&#8217; just to avoid namespace collisions.\u00a0 I&#8217;m lazy, not stupid.\u00a0 This could give us &#8216;morons.stupidmail.com&#8217;.<\/p>\n<p>And so we REVERSE that, yielding &#8216;moc.liamdiputs.snorom&#8217;.\u00a0 Then SPLIT at the first dot, yielding (on the left of the dot) the top level domain (TLD), which we will call &#8216;da_domaintop&#8217;, and on the right of the dot, the local part of the domain, which we call &#8216;da_domainlocal&#8217;.\u00a0 Good thing we aren&#8217;t working with AD or domain controllers etc.\u00a0 BUT we also must REVERSE these, so that our TLD which was &#8216;moc&#8217; becomes &#8216;com&#8217;, and our local domain which was &#8216;liamdiputs.snorom&#8217; becomes &#8216;morons.stupidmail&#8217;.<\/p>\n<p>We don&#8217;t actually need the &#8216;da_reverse&#8217; portion, but it is left in there for reference.\u00a0 My reference.\u00a0 So I can understand the rest.\u00a0 Why?\u00a0 Because I am too lazy to figure out CTEs or subqueries or whatever right now.\u00a0 So I have this poor machine rolling and unrolling, reversing and unreversing things all over the place.\u00a0 This is truly awful SQL.\u00a0 You see, I cannot simply define &#8216;da_reverse&#8217; and then WORK WITH IT, because until the blasted thing runs, &#8216;da_reverse&#8217; does not exist.\u00a0 So I have to go everywhere that I <em>would have wanted<\/em> to operate on &#8216;da_reverse&#8217; and PASTE IN the same operations which generated it.\u00a0 So it&#8217;s doing an astounding amount of unnecessary work, like James Joyce.\u00a0 Well better it than me!<\/p>\n<p>ANYWAY, this gives us some powerful tools.\u00a0 We can then group by TLD or local domain, and count the number of bogus users INFESTING MY BLOG who registered from each\/any of those domain parts.\u00a0 Here&#8217;s one of the possible outputs, grouping by &#8216;da_domainlocal&#8217;:<\/p>\n<table class=\"table table-striped table-hover table-sm table_results ajax w-auto pma_table\" data-uniqueid=\"499757844\">\n<thead>\n<tr>\n<th class=\"draggable position-sticky column_heading marker pointer\" data-column=\"da_domain\" aria-describedby=\"ui-id-27\"><a class=\"sortlink\" href=\"https:\/\/cpanel361.turbify.biz:2083\/cpsess4063224904\/3rdparty\/phpMyAdmin\/index.php\" data-post=\"route=\/sql&amp;db=v13272ff6bzkkbb1_blog&amp;table=wp_users&amp;sql_query=SELECT+%0D%0ASUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29+%0D%0A+++AS+da_domain%2C+%0D%0AREVERSE%28SUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29%29+%0D%0A+++AS+da_reverse%2C+%0D%0A%0D%0AREVERSE%28SUBSTRING%28REVERSE%28SUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29%29%2C+LOCATE%28%27.%27%2C+REVERSE%28SUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29%29%29+%2B+1%29%29++%0D%0A+++AS+da_domainlocal%2C%0D%0A%0D%0AREVERSE%28SUBSTRING%28REVERSE%28SUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29%29%2C1%2C+LOCATE%28%27.%27%2C+REVERSE%28SUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29%29%29+-+1%29%29+%0D%0A+++AS+da_domaintop%2C+%0D%0A%0D%0Acount%28%2A%29%0D%0AFROM+wp_users+%0D%0Agroup+by+da_domainlocal+%0AORDER+BY+%60da_domain%60+ASC+limit+1000&amp;sql_signature=341339c72afb8d4ffef69430d27f86c13ea84d7548c6483f958149f52d964205&amp;session_max_rows=25&amp;is_browse_distinct=0\">da_domain<\/a><\/th>\n<th class=\"draggable position-sticky column_heading marker pointer\" data-column=\"da_reverse\"><a class=\"sortlink\" href=\"https:\/\/cpanel361.turbify.biz:2083\/cpsess4063224904\/3rdparty\/phpMyAdmin\/index.php\" data-post=\"route=\/sql&amp;db=v13272ff6bzkkbb1_blog&amp;table=wp_users&amp;sql_query=SELECT+%0D%0ASUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29+%0D%0A+++AS+da_domain%2C+%0D%0AREVERSE%28SUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29%29+%0D%0A+++AS+da_reverse%2C+%0D%0A%0D%0AREVERSE%28SUBSTRING%28REVERSE%28SUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29%29%2C+LOCATE%28%27.%27%2C+REVERSE%28SUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29%29%29+%2B+1%29%29++%0D%0A+++AS+da_domainlocal%2C%0D%0A%0D%0AREVERSE%28SUBSTRING%28REVERSE%28SUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29%29%2C1%2C+LOCATE%28%27.%27%2C+REVERSE%28SUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29%29%29+-+1%29%29+%0D%0A+++AS+da_domaintop%2C+%0D%0A%0D%0Acount%28%2A%29%0D%0AFROM+wp_users+%0D%0Agroup+by+da_domainlocal+%0AORDER+BY+%60da_reverse%60+ASC+limit+1000&amp;sql_signature=0e40babac65f73646bb4679cc32e3f7135398cd548aa10dc651097f1e2ec4eb1&amp;session_max_rows=25&amp;is_browse_distinct=0\">da_reverse<\/a><\/th>\n<th class=\"draggable position-sticky column_heading marker pointer\" data-column=\"da_domainlocal\"><a class=\"sortlink\" href=\"https:\/\/cpanel361.turbify.biz:2083\/cpsess4063224904\/3rdparty\/phpMyAdmin\/index.php\" data-post=\"route=\/sql&amp;db=v13272ff6bzkkbb1_blog&amp;table=wp_users&amp;sql_query=SELECT+%0D%0ASUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29+%0D%0A+++AS+da_domain%2C+%0D%0AREVERSE%28SUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29%29+%0D%0A+++AS+da_reverse%2C+%0D%0A%0D%0AREVERSE%28SUBSTRING%28REVERSE%28SUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29%29%2C+LOCATE%28%27.%27%2C+REVERSE%28SUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29%29%29+%2B+1%29%29++%0D%0A+++AS+da_domainlocal%2C%0D%0A%0D%0AREVERSE%28SUBSTRING%28REVERSE%28SUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29%29%2C1%2C+LOCATE%28%27.%27%2C+REVERSE%28SUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29%29%29+-+1%29%29+%0D%0A+++AS+da_domaintop%2C+%0D%0A%0D%0Acount%28%2A%29%0D%0AFROM+wp_users+%0D%0Agroup+by+da_domainlocal+%0AORDER+BY+%60da_domainlocal%60+ASC+limit+1000&amp;sql_signature=740c67c152f7eaa9ca25e36bfabc75f97b0f414e71331e6d739756a83c460d8c&amp;session_max_rows=25&amp;is_browse_distinct=0\">da_domainlocal<\/a><\/th>\n<th class=\"draggable position-sticky column_heading marker pointer\" data-column=\"da_domaintop\"><a class=\"sortlink\" href=\"https:\/\/cpanel361.turbify.biz:2083\/cpsess4063224904\/3rdparty\/phpMyAdmin\/index.php\" data-post=\"route=\/sql&amp;db=v13272ff6bzkkbb1_blog&amp;table=wp_users&amp;sql_query=SELECT+%0D%0ASUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29+%0D%0A+++AS+da_domain%2C+%0D%0AREVERSE%28SUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29%29+%0D%0A+++AS+da_reverse%2C+%0D%0A%0D%0AREVERSE%28SUBSTRING%28REVERSE%28SUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29%29%2C+LOCATE%28%27.%27%2C+REVERSE%28SUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29%29%29+%2B+1%29%29++%0D%0A+++AS+da_domainlocal%2C%0D%0A%0D%0AREVERSE%28SUBSTRING%28REVERSE%28SUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29%29%2C1%2C+LOCATE%28%27.%27%2C+REVERSE%28SUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29%29%29+-+1%29%29+%0D%0A+++AS+da_domaintop%2C+%0D%0A%0D%0Acount%28%2A%29%0D%0AFROM+wp_users+%0D%0Agroup+by+da_domainlocal+%0AORDER+BY+%60da_domaintop%60+ASC+limit+1000&amp;sql_signature=9cda52d1cfc4ed5bcbba7408706451d1d379ef50b1378eca0e0af1c6066ace4b&amp;session_max_rows=25&amp;is_browse_distinct=0\">da_domaintop<\/a><\/th>\n<th class=\"draggable position-sticky text-end column_heading marker pointer\" data-column=\"count(*)\"><a class=\"sortlink\" href=\"https:\/\/cpanel361.turbify.biz:2083\/cpsess4063224904\/3rdparty\/phpMyAdmin\/index.php\" data-post=\"route=\/sql&amp;db=v13272ff6bzkkbb1_blog&amp;table=wp_users&amp;sql_query=SELECT+%0D%0ASUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29+%0D%0A+++AS+da_domain%2C+%0D%0AREVERSE%28SUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29%29+%0D%0A+++AS+da_reverse%2C+%0D%0A%0D%0AREVERSE%28SUBSTRING%28REVERSE%28SUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29%29%2C+LOCATE%28%27.%27%2C+REVERSE%28SUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29%29%29+%2B+1%29%29++%0D%0A+++AS+da_domainlocal%2C%0D%0A%0D%0AREVERSE%28SUBSTRING%28REVERSE%28SUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29%29%2C1%2C+LOCATE%28%27.%27%2C+REVERSE%28SUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29%29%29+-+1%29%29+%0D%0A+++AS+da_domaintop%2C+%0D%0A%0D%0Acount%28%2A%29%0D%0AFROM+wp_users+%0D%0Agroup+by+da_domainlocal+%0AORDER+BY+%60count%28%2A%29%60+ASC+limit+1000&amp;sql_signature=06b66f95ce919a2d8727d2a1c2f202547fa2704d16a34c46cccfa6ee6189488a&amp;session_max_rows=25&amp;is_browse_distinct=0\">count(*) <img decoding=\"async\" class=\"icon ic_s_desc soimg\" title=\"\" src=\"https:\/\/cpanel361.turbify.biz:2083\/cpsess4063224904\/3rdparty\/phpMyAdmin\/themes\/dot.gif\" alt=\"Descending\" \/><\/a><\/th>\n<td class=\"d-print-none\"><\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td class=\"data not_null text pre_wrap hover\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"9\">gmail.com<\/td>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"9\">moc.liamg<\/td>\n<td class=\"data not_null pre_wrap\" data-decimals=\"0\" data-type=\"blob\" data-originallength=\"5\">gmail<\/td>\n<td class=\"data not_null pre_wrap\" data-decimals=\"0\" data-type=\"blob\" data-originallength=\"3\">com<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">2998<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"9\">yahoo.com<\/td>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"9\">moc.oohay<\/td>\n<td class=\"data not_null pre_wrap\" data-decimals=\"0\" data-type=\"blob\" data-originallength=\"5\">yahoo<\/td>\n<td class=\"data not_null pre_wrap\" data-decimals=\"0\" data-type=\"blob\" data-originallength=\"3\">com<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">963<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"13\">hotmail.comom<\/td>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"13\">momoc.liamtoh<\/td>\n<td class=\"data not_null pre_wrap\" data-decimals=\"0\" data-type=\"blob\" data-originallength=\"7\">hotmail<\/td>\n<td class=\"data not_null pre_wrap\" data-decimals=\"0\" data-type=\"blob\" data-originallength=\"5\">comom<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">423<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"7\">meta.ua<\/td>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"7\">au.atem<\/td>\n<td class=\"data not_null pre_wrap\" data-decimals=\"0\" data-type=\"blob\" data-originallength=\"4\">meta<\/td>\n<td class=\"data not_null pre_wrap\" data-decimals=\"0\" data-type=\"blob\" data-originallength=\"2\">ua<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">375<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"16\">all.codyting.com<\/td>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"16\">moc.gnitydoc.lla<\/td>\n<td class=\"data not_null pre_wrap\" data-decimals=\"0\" data-type=\"blob\" data-originallength=\"12\">all.codyting<\/td>\n<td class=\"data not_null pre_wrap\" data-decimals=\"0\" data-type=\"blob\" data-originallength=\"3\">com<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">202<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"7\">aol.com<\/td>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"7\">moc.loa<\/td>\n<td class=\"data not_null pre_wrap\" data-decimals=\"0\" data-type=\"blob\" data-originallength=\"3\">aol<\/td>\n<td class=\"data not_null pre_wrap\" data-decimals=\"0\" data-type=\"blob\" data-originallength=\"3\">com<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">196<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"12\">thefmail.com<\/td>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"12\">moc.liamfeht<\/td>\n<td class=\"data not_null pre_wrap\" data-decimals=\"0\" data-type=\"blob\" data-originallength=\"8\">thefmail<\/td>\n<td class=\"data not_null pre_wrap\" data-decimals=\"0\" data-type=\"blob\" data-originallength=\"3\">com<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">135<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"11\">comcast.net<\/td>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"11\">ten.tsacmoc<\/td>\n<td class=\"data not_null pre_wrap\" data-decimals=\"0\" data-type=\"blob\" data-originallength=\"7\">comcast<\/td>\n<td class=\"data not_null pre_wrap\" data-decimals=\"0\" data-type=\"blob\" data-originallength=\"3\">net<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">73<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>As you can see, the bulk of the remaining users are here from gmail, but this is out of over eleven thousand remaining users, to that nearly 3K does not tell much of the story.\u00a0 Obviously, I can delete all users coming from the nonsense domain &#8216;hotmail.comom&#8217;.\u00a0 Jut as obviously, I should not delete the populations of yahoo, gmail, aol, and so forth.\u00a0 There could be real people in there.\u00a0 For those, my next bulk-reducing trick will be to count the number of periods in the local part of the email address, which will get a lot for very little effort.\u00a0 These guys:\u00a0 ev.il.sp.am.mer.84383@whatever.<\/p>\n<p>There&#8217;s an issue hiding in the data above, which is that I have overspecified (grabbed too many fields), and the results are not what they appear.\u00a0 Because the table above was ordered up with GROUP BY &#8216;da_domainlocal&#8217; and so forth, the count only applies to THAT column, and any data listed alongside in other columns is only an example, selected essentially at random.\u00a0 That is, YES it is true that there are 423 hotmail.[something] accounts, but I only know that at least one of them is actually hotmail.comom.\u00a0 The rest are very likely hotmail.com.\u00a0 So it is important to know what this barbaric SQL is saying and what it is NOT saying.<\/p>\n<p>So you get domains like yandex, which is the same as the search engine problem for frigging pinterest.\u00a0 I do not <em>ever<\/em> want pinterest to show up in my search results.\u00a0 Unfortunately, you cannot just block pinterest.com, as that miserable noise content comes from everywhere &#8212; pinterest.com, pinterest.co.us, pinterest.co.jp, pinterest.co.cn, pinterest.co.ca, pinterest.co.tk, and it just never ends.\u00a0 Pinterest links are the real cosmic noise background. Well, now DuckDuckGo <em>now<\/em> supports wildcards in the filters for result domains, but they didn&#8217;t always.\u00a0 Which brings us back to yandex, and yahoo for that matter, and probably gmail now that I think about it.\u00a0 Haven&#8217;t looked that far yet.<\/p>\n<table class=\"table table-striped table-hover table-sm table_results ajax w-auto pma_table\" data-uniqueid=\"266371543\">\n<thead>\n<tr>\n<th class=\"draggable position-sticky column_heading marker pointer\" data-column=\"da_domain\"><a class=\"sortlink\" href=\"https:\/\/cpanel361.turbify.biz:2083\/cpsess4063224904\/3rdparty\/phpMyAdmin\/index.php?route=\/sql&amp;db=v13272ff6bzkkbb1_blog&amp;table=wp_users&amp;sql_query=SELECT+%0D%0ASUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29+%0D%0A+++AS+da_domain%2C+%0D%0A%0D%0Acount%28%2A%29%0D%0AFROM+wp_users+%0D%0Agroup+by+da_domain+%0AORDER+BY+%60da_domain%60+ASC+limit+1000&amp;sql_signature=ecb1ca1e94a9a558cd4610c8fbef36e440a0c8195566dec399c6b517e84ee2b0&amp;session_max_rows=25&amp;is_browse_distinct=0\">da_domain <img decoding=\"async\" class=\"icon ic_s_desc soimg\" title=\"\" src=\"https:\/\/cpanel361.turbify.biz:2083\/cpsess4063224904\/3rdparty\/phpMyAdmin\/themes\/dot.gif\" alt=\"Descending\" \/> <small>1<\/small><\/a><\/th>\n<th class=\"draggable position-sticky text-end column_heading marker pointer\" data-column=\"count(*)\"><a class=\"sortlink\" href=\"https:\/\/cpanel361.turbify.biz:2083\/cpsess4063224904\/3rdparty\/phpMyAdmin\/index.php?route=\/sql&amp;db=v13272ff6bzkkbb1_blog&amp;table=wp_users&amp;sql_query=SELECT+%0D%0ASUBSTRING%28user_email%2C+LOCATE%28%27%40%27%2C+user_email%29+%2B+1%29+%0D%0A+++AS+da_domain%2C+%0D%0A%0D%0Acount%28%2A%29%0D%0AFROM+wp_users+%0D%0Agroup+by+da_domain+%0AORDER+BY+%60count%28%2A%29%60+ASC+limit+1000&amp;sql_signature=1a0f7f0e7f6f331f8cf93ecda1f67913930d0f9f9672d3601b0e9a7f85c6b9d7&amp;session_max_rows=25&amp;is_browse_distinct=0\">count(*)<\/a><\/th>\n<td class=\"d-print-none\"><\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td class=\"data not_null text pre_wrap marked hover\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"16\">zuxuhanuvunu.pro<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">1<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap marked hover\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"16\">&#8230;<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">&#8230;<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"21\">yaroslav-samoylov.com<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">1<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"9\">yandex.ua<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">6<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"9\">yandex.kz<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">10<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"9\">yandex.by<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">5<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"10\">yaicae.fun<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">1<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"8\">yahoo.it<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">1<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"8\">yahoo.in<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">1<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"8\">yahoo.fr<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">1<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"8\">yahoo.es<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">3<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"8\">yahoo.de<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">1<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"12\">yahoo.com.sg<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">1<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"9\">yahoo.com<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">950<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"11\">yahoo.co.uk<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">9<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"11\">yahoo.co.jp<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">2<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"11\">yahoo.co.in<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">1<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"8\">yahoo.co<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">3<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"8\">yahoo.ca<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">3<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null text pre_wrap\" data-decimals=\"0\" data-type=\"string\" data-originallength=\"16\">y.otramovida.net<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>This is when it&#8217;s handy to use the domainlocal part, which reduces like this:<\/p>\n<table class=\"table table-striped table-hover table-sm table_results ajax w-auto pma_table\" data-uniqueid=\"1974618956\">\n<tbody>\n<tr>\n<td class=\"data not_null pre_wrap\" data-decimals=\"0\" data-type=\"blob\" data-originallength=\"17\">yaroslav-samoylov<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">1<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null pre_wrap\" data-decimals=\"0\" data-type=\"blob\" data-originallength=\"6\">yandex<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">21<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null pre_wrap\" data-decimals=\"0\" data-type=\"blob\" data-originallength=\"6\">yaicae<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">1<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null pre_wrap\" data-decimals=\"0\" data-type=\"blob\" data-originallength=\"9\">yahoo.com<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">1<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null pre_wrap\" data-decimals=\"0\" data-type=\"blob\" data-originallength=\"8\">yahoo.co<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">12<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null pre_wrap\" data-decimals=\"0\" data-type=\"blob\" data-originallength=\"5\">yahoo<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">963<\/td>\n<\/tr>\n<tr>\n<td class=\"data not_null pre_wrap\" data-decimals=\"0\" data-type=\"blob\" data-originallength=\"12\">y.otramovida<\/td>\n<td class=\"text-end data not_null text-nowrap\" data-decimals=\"0\" data-type=\"int\">6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>It&#8217;s not perfect, but it&#8217;s better, and it is informative.<\/p>\n<p>I would really need to get into CTEs, potentially recursive due to the recursive nature of domain names, in order to formalize numbers about domains and so forth.<\/p>\n<p>You may wonder what the point of all this is, as easy answers are not exactly popping out of the woodwork here.\u00a0 Well, I already scooped up a bunch of the easy answers, deleting about 7K bogus users just by looking at obvious nonsense domains right out of the WordPress user management screen and then finding, filtering, and deleting matches for those.\u00a0 Really, the next valuable thing I could do is probably look for users whose email addresses are festooned with too many dot characters.\u00a0 They do that to break up the bad word filters, and wind up creating a far handier tell.\u00a0 but that&#8217;s not going so tolve alot of problems.\u00a0 To be most effective that search will be conducted without reference to domains at all :-\/<\/p>\n<p>I&#8217;ve wanted to develop this capacity for some time &#8212; I still have nearly 90K comments on another blog that I have to get rid of.\u00a0 That will of course be done by finding bad users and deleting them, and their comment go with them.\u00a0 But this one is priority.<\/p>\n<p>As I get further into reminding myself how SQL works, eventually I will get brave enough to run DELETE queries.\u00a0 For now, it&#8217;s just SELECT to point me toward value-added manual deletion activities, and so it goes, like Kurt Vonnegut.\u00a0 Sigh.<\/p>\n<p>Well, in case you wanted some truly disgusting, abusive SQL (not even in a clever sense), I got you covered.<\/p>\n<div class=\"pld-like-dislike-wrap pld-template-1\">\r\n    <div class=\"pld-like-wrap  pld-common-wrap\">\r\n    <a href=\"https:\/\/balldiamondball.com\/blog\/wp-login.php\" class=\"pld-like-trigger pld-like-dislike-trigger  \" title=\"\" data-post-id=\"5558\" data-trigger-type=\"like\" data-restriction=\"user\" data-already-liked=\"0\">\r\n                        <i class=\"fas fa-thumbs-up\"><\/i>\r\n                <\/a>\r\n    <span class=\"pld-like-count-wrap pld-count-wrap\">    <\/span>\r\n<\/div><div class=\"pld-dislike-wrap  pld-common-wrap\">\r\n    <a href=\"https:\/\/balldiamondball.com\/blog\/wp-login.php\" class=\"pld-dislike-trigger pld-like-dislike-trigger  \" title=\"\" data-post-id=\"5558\" data-trigger-type=\"dislike\" data-restriction=\"user\" data-already-liked=\"0\">\r\n                        <i class=\"fas fa-thumbs-down\"><\/i>\r\n                <\/a>\r\n    <span class=\"pld-dislike-count-wrap pld-count-wrap\"><\/span>\r\n<\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Yeah yeah, don&#8217;t carp to me about SQL.\u00a0 I&#8217;ll have you know that the language is mathematically derived, and is <em>the correct way<\/em> to deal with data.\u00a0 God Bless all those elementary school teachers who tried to impress upon us the importance of the intersection of the set of all apples and the set of all thing that Johnny possessed, as they were on to someting, but they didn&#8217;t understand it any more than we did, and it showed.\u00a0 They had the teachers&#8217; edition and we did not, and that was that.<\/p>\n<p>That nonsense of apples and Johnnies is a problem which still plagues database instruction to this day.\u00a0 Do you know the name Alfreds Futterkiste?\u00a0 I&#8217;ll stab that bastard if I ever see him.\u00a0 I recently saw &#8230; <a href=\"https:\/\/balldiamondball.com\/blog\/some-horrific-sql\/\"> Continue reading <span class=\"meta-nav\">&rarr; <\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5558","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/balldiamondball.com\/blog\/wp-json\/wp\/v2\/posts\/5558","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/balldiamondball.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/balldiamondball.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/balldiamondball.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/balldiamondball.com\/blog\/wp-json\/wp\/v2\/comments?post=5558"}],"version-history":[{"count":4,"href":"https:\/\/balldiamondball.com\/blog\/wp-json\/wp\/v2\/posts\/5558\/revisions"}],"predecessor-version":[{"id":5562,"href":"https:\/\/balldiamondball.com\/blog\/wp-json\/wp\/v2\/posts\/5558\/revisions\/5562"}],"wp:attachment":[{"href":"https:\/\/balldiamondball.com\/blog\/wp-json\/wp\/v2\/media?parent=5558"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/balldiamondball.com\/blog\/wp-json\/wp\/v2\/categories?post=5558"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/balldiamondball.com\/blog\/wp-json\/wp\/v2\/tags?post=5558"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}