snipt

Ctrl+h for KB shortcuts

PHP

wp dev stats

< ?php echo get_num_queries(); ?> queries.
< ?php timer_stop(1); ?> seconds.
https://snipt.net/embed/15fd0ba15d8a622ca36249cd093c4e6c/
https://snipt.net/raw/15fd0ba15d8a622ca36249cd093c4e6c/
15fd0ba15d8a622ca36249cd093c4e6c
php
PHP
2
2016-09-22T17:03:19
True
False
False
/api/public/snipt/34239/
wp-dev-stats
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="x">&lt; ?php echo get_num_queries(); ?&gt; queries.</span> </span><span id="L-2"><a name="L-2"></a><span class="x">&lt; ?php timer_stop(1); ?&gt; seconds.</span> </span></pre></div> </td></tr></table>
queries, stats, wp

MySQL

mysql duplicate finder

1
2
3
4
5
6
select * from (
    select survey_id, count(*) as count 
        from sleep group by survey_id) as x 
join sleep USING (survey_id) 
join survey y ON (y.id=sleep.survey_id) 
where type='baseline' AND count > 1;
https://snipt.net/embed/a79a5772e959d11426f5dd90dd638940/
https://snipt.net/raw/a79a5772e959d11426f5dd90dd638940/
a79a5772e959d11426f5dd90dd638940
mysql
MySQL
6
2016-09-23T08:20:28
True
False
False
/api/public/snipt/27675/
mysql-duplicate-finder
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="k">select</span> <span class="o">*</span> <span class="k">from</span> <span class="p">(</span> </span><span id="L-2"><a name="L-2"></a> <span class="k">select</span> <span class="n">survey_id</span><span class="p">,</span> <span class="nf">count</span><span class="p">(</span><span class="o">*</span><span class="p">)</span> <span class="k">as</span> <span class="n">count</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">from</span> <span class="n">sleep</span> <span class="k">group</span> <span class="k">by</span> <span class="n">survey_id</span><span class="p">)</span> <span class="k">as</span> <span class="n">x</span> </span><span id="L-4"><a name="L-4"></a><span class="k">join</span> <span class="n">sleep</span> <span class="k">USING</span> <span class="p">(</span><span class="n">survey_id</span><span class="p">)</span> </span><span id="L-5"><a name="L-5"></a><span class="k">join</span> <span class="n">survey</span> <span class="n">y</span> <span class="k">ON</span> <span class="p">(</span><span class="n">y</span><span class="p">.</span><span class="n">id</span><span class="o">=</span><span class="n">sleep</span><span class="p">.</span><span class="n">survey_id</span><span class="p">)</span> </span><span id="L-6"><a name="L-6"></a><span class="k">where</span> <span class="n">type</span><span class="o">=</span><span class="s1">&#39;baseline&#39;</span> <span class="k">AND</span> <span class="n">count</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">;</span> </span></pre></div> </td></tr></table>
mysql, queries

MySQL

MySQL csv export

1
2
3
4
SELECT a,b,a+b INTO OUTFILE '/tmp/result.text'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM test_table;
https://snipt.net/embed/bdfce617199644b735bf776b3b94d900/
https://snipt.net/raw/bdfce617199644b735bf776b3b94d900/
bdfce617199644b735bf776b3b94d900
mysql
MySQL
6
2016-09-16T19:01:53
True
False
False
/api/public/snipt/23989/
mysql-csv-export
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="k">SELECT</span> <span class="n">a</span><span class="p">,</span><span class="n">b</span><span class="p">,</span><span class="n">a</span><span class="o">+</span><span class="n">b</span> <span class="k">INTO</span> <span class="k">OUTFILE</span> <span class="s1">&#39;/tmp/result.text&#39;</span> </span><span id="L-2"><a name="L-2"></a><span class="n">FIELDS</span> <span class="k">TERMINATED</span> <span class="k">BY</span> <span class="s1">&#39;,&#39;</span> <span class="k">OPTIONALLY</span> <span class="k">ENCLOSED</span> <span class="k">BY</span> <span class="s1">&#39;&quot;&#39;</span> </span><span id="L-3"><a name="L-3"></a><span class="k">LINES</span> <span class="k">TERMINATED</span> <span class="k">BY</span> <span class="s1">&#39;\n&#39;</span> </span><span id="L-4"><a name="L-4"></a><span class="k">FROM</span> <span class="n">test_table</span><span class="p">;</span> </span></pre></div> </td></tr></table>
mysql, queries

MySQL

Fix email address whos domain name got truncated

1
2
3
4
# fix an email address whose domain name got truncated
SELECT CONCAT(x.name,'@cityofs.org') FROM 
(SELECT SUBSTRING_INDEX(email,'@',1) AS name FROM sf_guard_user_profile 
WHERE code like 'XXXX%' AND SUBSTRING_INDEX(email,'@',-1) LIKE '%cityofsa%') AS x
https://snipt.net/embed/8b17e210c7ccadd40594699ec997e973/
https://snipt.net/raw/8b17e210c7ccadd40594699ec997e973/
8b17e210c7ccadd40594699ec997e973
mysql
MySQL
4
2016-09-21T14:58:39
True
False
False
/api/public/snipt/23500/
fix-email-address-whos-domain-name-got-truncated
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="c1"># fix an email address whose domain name got truncated</span> </span><span id="L-2"><a name="L-2"></a><span class="k">SELECT</span> <span class="nf">CONCAT</span><span class="p">(</span><span class="n">x</span><span class="p">.</span><span class="n">name</span><span class="p">,</span><span class="s1">&#39;@cityofs.org&#39;</span><span class="p">)</span> <span class="k">FROM</span> </span><span id="L-3"><a name="L-3"></a><span class="p">(</span><span class="k">SELECT</span> <span class="nf">SUBSTRING_INDEX</span><span class="p">(</span><span class="n">email</span><span class="p">,</span><span class="s1">&#39;@&#39;</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span> <span class="k">AS</span> <span class="n">name</span> <span class="k">FROM</span> <span class="n">sf_guard_user_profile</span> </span><span id="L-4"><a name="L-4"></a><span class="k">WHERE</span> <span class="n">code</span> <span class="k">like</span> <span class="s1">&#39;XXXX%&#39;</span> <span class="k">AND</span> <span class="nf">SUBSTRING_INDEX</span><span class="p">(</span><span class="n">email</span><span class="p">,</span><span class="s1">&#39;@&#39;</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="k">LIKE</span> <span class="s1">&#39;%cityofsa%&#39;</span><span class="p">)</span> <span class="k">AS</span> <span class="n">x</span> </span></pre></div> </td></tr></table>
email, mysql, queries
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.