<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SQL &#8211; CodePills.com</title>
	<atom:link href="https://codepills.com/tag/sql/feed/" rel="self" type="application/rss+xml" />
	<link>https://codepills.com</link>
	<description>Helping you make a better code</description>
	<lastBuildDate>Sun, 19 Jun 2022 16:02:27 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>SQL &#8211; How to use NOT LIKE in SQL?</title>
		<link>https://codepills.com/sql-how-to-use-not-like-in-sql/</link>
					<comments>https://codepills.com/sql-how-to-use-not-like-in-sql/#respond</comments>
		
		<dc:creator><![CDATA[Andrej Buday]]></dc:creator>
		<pubDate>Sun, 02 Jun 2019 08:30:09 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[LIKE]]></category>
		<category><![CDATA[NOT]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[TDD]]></category>
		<guid isPermaLink="false">http://www.budystudio.com/design/?p=21</guid>

					<description><![CDATA[This article demonstrates the usage of SQL's NOT LIKE on example. <a href="https://codepills.com/sql-how-to-use-not-like-in-sql/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[<p>I had a problem with one column where corrupted data occurred. Column stored images in the base64 form. However, because of the programming error, it was sometimes also storing image description on image removal.</p>
<p>This article will demonstrate the usage of SQL&#8217;s NOT LIKE command in this example.</p>
<p><span id="more-21"></span></p>
<p>Luckily I was also using soft removal in the same application. So the unique record will be forever in the database but marked as removed.</p>
<p>Note: To prevent such issues is fundamental to practice TDD.</p>
<p>After patching the application code, fixing the database with SQL magic should be easy. All I needed to do was update rows in the image column which did not contain correct records. Unfortunately, if the image was stored, it might not be stored in reality. Image description would be stored instead, and image data would be lost forever.</p>
<p>Instead of writing SQL regex (which is in a certain degree of their creator prone to error), I have decided to use a simple  <code>NOT LIKE</code> SQL solution. So if the record is removed and does not contain an image string in the required format, the data cell should be blank.</p>
<p>Since everything behind <code>data:image/png;base64,</code> is base64 representation of image we will use <code>%</code> as replacing character.</p>
<p>Here follows is a simple example of an SQL command using the NOT LIKE format:</p>
<pre><code class="language-sql">UPDATE app.device
SET image = ''
WHERE device.removed = TRUE
AND NOT (device.image LIKE 'data:image/png;base64,%');</code></pre>
<p>The following example is how we update columns using <code>NOT LIKE</code> command.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://codepills.com/sql-how-to-use-not-like-in-sql/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
