<?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>comma separated &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/comma-separated/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Fri, 29 Sep 2017 06:37:26 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.4</generator>
	<item>
		<title>MySQL: UDF to SELECT value from a Comma Separated String at any position</title>
		<link>https://www.dbrnd.com/2016/10/mysql-udf-to-select-value-from-a-comma-separated-string-at-any-position/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 15 Oct 2016 16:16:00 +0000</pubDate>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[comma separated]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[MySQL Command]]></category>
		<category><![CDATA[MySQL Database Administrator]]></category>
		<category><![CDATA[MySQL Database Designing]]></category>
		<category><![CDATA[MySQL Database Programming]]></category>
		<category><![CDATA[MySQL Error]]></category>
		<category><![CDATA[MySQL Performance Tunning]]></category>
		<category><![CDATA[MySQL Query]]></category>
		<category><![CDATA[MySQL Tips and Tricks]]></category>
		<category><![CDATA[split]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=2139</guid>

					<description><![CDATA[In this post, I am sharing one user defined function to select a particular value from comma separated string in the MySQL. In our MySQL Database, we are managing some of the table in which we are storing dynamic content management system (CMS) related data. As per the requirement, we are also storing comma delimited [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F10%2Fmysql-udf-to-select-value-from-a-comma-separated-string-at-any-position%2F&amp;linkname=MySQL%3A%20UDF%20to%20SELECT%20value%20from%20a%20Comma%20Separated%20String%20at%20any%20position" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F10%2Fmysql-udf-to-select-value-from-a-comma-separated-string-at-any-position%2F&amp;linkname=MySQL%3A%20UDF%20to%20SELECT%20value%20from%20a%20Comma%20Separated%20String%20at%20any%20position" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F10%2Fmysql-udf-to-select-value-from-a-comma-separated-string-at-any-position%2F&amp;linkname=MySQL%3A%20UDF%20to%20SELECT%20value%20from%20a%20Comma%20Separated%20String%20at%20any%20position" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F10%2Fmysql-udf-to-select-value-from-a-comma-separated-string-at-any-position%2F&amp;linkname=MySQL%3A%20UDF%20to%20SELECT%20value%20from%20a%20Comma%20Separated%20String%20at%20any%20position" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F10%2Fmysql-udf-to-select-value-from-a-comma-separated-string-at-any-position%2F&amp;linkname=MySQL%3A%20UDF%20to%20SELECT%20value%20from%20a%20Comma%20Separated%20String%20at%20any%20position" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F10%2Fmysql-udf-to-select-value-from-a-comma-separated-string-at-any-position%2F&amp;linkname=MySQL%3A%20UDF%20to%20SELECT%20value%20from%20a%20Comma%20Separated%20String%20at%20any%20position" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F10%2Fmysql-udf-to-select-value-from-a-comma-separated-string-at-any-position%2F&#038;title=MySQL%3A%20UDF%20to%20SELECT%20value%20from%20a%20Comma%20Separated%20String%20at%20any%20position" data-a2a-url="https://www.dbrnd.com/2016/10/mysql-udf-to-select-value-from-a-comma-separated-string-at-any-position/" data-a2a-title="MySQL: UDF to SELECT value from a Comma Separated String at any position"></a></p><p>In this post, I am sharing one user defined function to select a particular value from comma separated string in the MySQL.</p>
<blockquote><p>In our MySQL Database, we are managing some of the table in which we are storing dynamic content management system (CMS) related data.<br />
As per the requirement, we are also storing comma delimited values in some the tables.</p></blockquote>
<blockquote><p>Now the requirement is to find third value from each comma separated string.<br />
I have created one user defined function to solve this problem.</p></blockquote>
<p><strong>First, Create UDF to split and select a particular value from comma separated string:</strong><br />
Three parameters require: Delimited_String, Delimited_Character, and Position.</p><pre class="crayon-plain-tag">CREATE FUNCTION fn_Get_Split_String
(
    DelimitedString VARCHAR(255)
    ,DelimitedCharacter VARCHAR(12)
    ,Position INT
)RETURNS VARCHAR(255)

RETURN 
   REPLACE(SUBSTRING(SUBSTRING_INDEX(DelimitedString, DelimitedCharacter, Position)
   ,LENGTH(SUBSTRING_INDEX(DelimitedString, DelimitedCharacter, Position-1)) + 1)
   ,DelimitedCharacter, '');</pre><p>
<strong>Create a table with sample data:</strong></p><pre class="crayon-plain-tag">CREATE TABLE tbl_CommaSeparated
(
    ID INTEGER
    ,CommaDelimited TEXT
);

INSERT INTO tbl_CommaSeparated
VALUES
(1,'A,B,C,D,E,F')
,(2,'12,45,89,36,88')
,(3,'a,b,c,d,e,f');</pre><p>
<strong>Using UDF, SELECT second value from each comma separated string:</strong></p><pre class="crayon-plain-tag">SELECT fn_Get_Split_String(CommaDelimited,',',2) AS ResultData 
FROM tbl_CommaSeparated;</pre><p>
<strong>The Result:</strong></p>
<p><a href="https://www.dbrnd.com/wp-content/uploads/2016/03/MySQLCommaSeparatedValues.png" rel="attachment wp-att-2143"><img decoding="async" class="alignnone wp-image-2143 size-full" title="MySQL Comma Separated Values" src="https://www.dbrnd.com/wp-content/uploads/2016/03/MySQLCommaSeparatedValues.png" alt="MySQL Comma Separated Values" width="84" height="108" /></a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Database Design: Storing a comma separated list in a Database, Is a Bad Practice?</title>
		<link>https://www.dbrnd.com/2016/01/database-design-storing-a-comma-separated-list-in-a-database-is-a-bad-practice/</link>
					<comments>https://www.dbrnd.com/2016/01/database-design-storing-a-comma-separated-list-in-a-database-is-a-bad-practice/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 28 Jan 2016 19:56:25 +0000</pubDate>
				<category><![CDATA[Database Designing]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[comma separated]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database concept]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[database standards]]></category>
		<category><![CDATA[Database Theory]]></category>
		<category><![CDATA[database topic]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[delimited list]]></category>
		<category><![CDATA[RDBMS]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=1404</guid>

					<description><![CDATA[Should we store comma &#8211; separated list in a database? My suggestion and answer are: Never store comma &#8211; separated or delimited list in a Database. I found this discussion in many forums and blogs so, in this post, I would like to share my opinions and views on this topic. Why we should not [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F01%2Fdatabase-design-storing-a-comma-separated-list-in-a-database-is-a-bad-practice%2F&amp;linkname=Database%20Design%3A%20Storing%20a%20comma%20separated%20list%20in%20a%20Database%2C%20Is%20a%20Bad%20Practice%3F" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F01%2Fdatabase-design-storing-a-comma-separated-list-in-a-database-is-a-bad-practice%2F&amp;linkname=Database%20Design%3A%20Storing%20a%20comma%20separated%20list%20in%20a%20Database%2C%20Is%20a%20Bad%20Practice%3F" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F01%2Fdatabase-design-storing-a-comma-separated-list-in-a-database-is-a-bad-practice%2F&amp;linkname=Database%20Design%3A%20Storing%20a%20comma%20separated%20list%20in%20a%20Database%2C%20Is%20a%20Bad%20Practice%3F" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F01%2Fdatabase-design-storing-a-comma-separated-list-in-a-database-is-a-bad-practice%2F&amp;linkname=Database%20Design%3A%20Storing%20a%20comma%20separated%20list%20in%20a%20Database%2C%20Is%20a%20Bad%20Practice%3F" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F01%2Fdatabase-design-storing-a-comma-separated-list-in-a-database-is-a-bad-practice%2F&amp;linkname=Database%20Design%3A%20Storing%20a%20comma%20separated%20list%20in%20a%20Database%2C%20Is%20a%20Bad%20Practice%3F" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F01%2Fdatabase-design-storing-a-comma-separated-list-in-a-database-is-a-bad-practice%2F&amp;linkname=Database%20Design%3A%20Storing%20a%20comma%20separated%20list%20in%20a%20Database%2C%20Is%20a%20Bad%20Practice%3F" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F01%2Fdatabase-design-storing-a-comma-separated-list-in-a-database-is-a-bad-practice%2F&#038;title=Database%20Design%3A%20Storing%20a%20comma%20separated%20list%20in%20a%20Database%2C%20Is%20a%20Bad%20Practice%3F" data-a2a-url="https://www.dbrnd.com/2016/01/database-design-storing-a-comma-separated-list-in-a-database-is-a-bad-practice/" data-a2a-title="Database Design: Storing a comma separated list in a Database, Is a Bad Practice?"></a></p><p><strong>Should we store comma &#8211; separated list in a database?<br />
My suggestion and answer are: Never store comma &#8211; separated or delimited list in a Database. </strong></p>
<p>I found this discussion in many forums and blogs so, in this post, I would like to share my opinions and views on this topic.</p>
<p><strong>Why we should not store comma &#8211; separated or delimited list?</strong></p>
<blockquote><p>We cannot enforce uniqueness inside the list, e.g. list can be like this: 5, 4, 8, 8, 8, 6.</p></blockquote>
<blockquote><p>We cannot ensure right data-type for all the values, e.g. list can be like this: 5, 8, 7, temp, abc, $, 8.</p></blockquote>
<blockquote><p>Do not possible to check referential integrity.</p></blockquote>
<blockquote><p>It is tough to search any data or value from the list and sometimes we have to use regular expressions to search the string.</p></blockquote>
<blockquote><p>We cannot perform any DML operation on a single value from the list without fetching the whole list.</p></blockquote>
<blockquote><p>Getting all the records in sorted order is tough.</p></blockquote>
<blockquote><p>Counting elements from the list is terrible.</p></blockquote>
<blockquote><p>When we are storing integer data into the list, it takes twice the space than binary integers.</p></blockquote>
<blockquote><p>We cannot use list value in the join conditions.</p></blockquote>
<blockquote><p>When we store the comma separated value, the overall maintenance of this list and data is complicated.</p></blockquote>
<p><strong>The simplest solution of this problem,</strong> is to create a separate table, or you can use data type like XML, JSON. </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/01/database-design-storing-a-comma-separated-list-in-a-database-is-a-bad-practice/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
