<?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>Mukesh Chapagain&#039;s Blog &#187; query</title>
	<atom:link href="http://blog.chapagain.com.np/tag/query/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.chapagain.com.np</link>
	<description>PHP Magento jQuery SQL Wordpress Joomla Programming &#38; Tutorial</description>
	<lastBuildDate>Tue, 07 Feb 2012 00:54:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Magento: Join, filter, select and sort attributes, fields and tables</title>
		<link>http://blog.chapagain.com.np/magento-join-filter-select-and-sort-attributes-fields-and-tables/</link>
		<comments>http://blog.chapagain.com.np/magento-join-filter-select-and-sort-attributes-fields-and-tables/#comments</comments>
		<pubDate>Mon, 15 Nov 2010 14:34:06 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[attribute]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[join]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[table]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=981</guid>
		<description><![CDATA[In my previous article (Magento: Very Useful Collection Functions), I had written about database interaction functions present in class Varien_Data_Collection_Db. Here, I am going to explain some database interaction functions present in the class Mage_Eav_Model_Entity_Collection_Abstract. These collection functions are very useful to select data from Magento database. We need them almost all the time for [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/magento-how-to-filter-product-collection-using-2-or-more-category-filters/' rel='bookmark' title='Permanent Link: Magento: How to filter product collection using 2 or more category filters?'>Magento: How to filter product collection using 2 or more category filters?</a></li>
<li><a href='http://blog.chapagain.com.np/magento-collection-functions/' rel='bookmark' title='Permanent Link: Magento: Very Useful Collection Functions'>Magento: Very Useful Collection Functions</a></li>
<li><a href='http://blog.chapagain.com.np/magento-adding-category-attributes/' rel='bookmark' title='Permanent Link: Magento: Adding category attributes'>Magento: Adding category attributes</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-search-or-filter-by-multiselect-attribute-in-admin-grid/' rel='bookmark' title='Permanent Link: Magento: How to search or filter by multiselect attribute in admin grid?'>Magento: How to search or filter by multiselect attribute in admin grid?</a></li>
<li><a href='http://blog.chapagain.com.np/magento-sort-latest-product-by-created-date-and-new-from-date/' rel='bookmark' title='Permanent Link: Magento: Sort latest product by &#8216;created date&#8217; and &#8216;new from date&#8217;'>Magento: Sort latest product by &#8216;created date&#8217; and &#8216;new from date&#8217;</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>In my previous article (<strong><a href="http://blog.chapagain.com.np/magento-collection-functions/">Magento: Very Useful Collection Functions</a></strong>), I had written about database interaction functions present in class <strong>Varien_Data_Collection_Db</strong>.</p>
<p>Here, I am going to explain some database interaction functions present in the class <strong>Mage_Eav_Model_Entity_Collection_Abstract</strong>. These collection functions are very useful to select data from Magento database. We need them almost all the time for filtering collection object.</p>
<p><span id="more-981"></span></p>
<p>Below are some of the useful functions that we use most often.</p>
<p><strong>Class: Mage_Eav_Model_Entity_Collection_Abstract</strong></p>
<p><strong>addAttributeToFilter</strong>: adds WHERE clause on $attribute specified by $condition</p>
<blockquote><p>
/**<br />
* Add attribute filter to collection<br />
*<br />
* If $attribute is an array will add OR condition with following format:<br />
* array(<br />
*     array(&#8216;attribute&#8217;=&gt;&#8217;firstname&#8217;, &#8216;like&#8217;=&gt;&#8217;test%&#8217;),<br />
*     array(&#8216;attribute&#8217;=&gt;&#8217;lastname&#8217;, &#8216;like&#8217;=&gt;&#8217;test%&#8217;),<br />
* )<br />
*<br />
* @see self::_getConditionSql for $condition<br />
* @param Mage_Eav_Model_Entity_Attribute_Interface|integer|string|array $attribute<br />
* @param null|string|array $condition<br />
* @param string $operator<br />
* @return Mage_Eav_Model_Entity_Collection_Abstract<br />
*/<br />
addAttributeToFilter($attribute, $condition=null, $joinType=&#8217;inner&#8217;)
</p></blockquote>
<p><strong>addAttributeToSelect</strong>: gets the value for $attribute in the SELECT clause; specify * to get all attributes (i.e. to execute SELECT *)</p>
<blockquote><p>
/**<br />
* Add attribute to entities in collection<br />
*<br />
* If $attribute==&#8217;*&#8217; select all attributes<br />
*<br />
* @param   array|string|integer|Mage_Core_Model_Config_Element $attribute<br />
* @param   false|string $joinType flag for joining attribute<br />
* @return  Mage_Eav_Model_Entity_Collection_Abstract<br />
*/<br />
addAttributeToSelect($attribute, $joinType=false)
</p></blockquote>
<p>If an array is passed but no attribute code specified, it will be interpreted as a group of OR conditions that will be processed in the same way.<br />
If no attribute code is specified, it defaults to eq.</p>
<pre class="brush: php; title: ; notranslate">
$collection = Mage::getModel('catalog/product')-&gt;getCollection();

// select all attributes
$collection-&gt;addAttributeToSelect('*');

// select specific attributes
$collection-&gt;addAttributeToSelect(array('name', 'url_key', 'type_id'));

// select only those items whose status = 1
$collection-&gt;addAttributeToFilter('status', 1);

// alternative to select only those items whose status = 1
$collection-&gt;addAttributeToFilter('status', array('eq' =&gt; 1));

// using LIKE statement
$collection-&gt;addAttributeToFilter('sku', array('like' =&gt; '%CH%'));

// using IN statement,
// i.e. selecting only those items whose ID fall in the given array
$collection-&gt;addAttributeToFilter('id', array('in' =&gt; array(1, 14, 51, 52)));

// selecting only those items whose ID is greater than the given value
$collection-&gt;addAttributeToFilter('id', array('gt' =&gt; 5));

// select by date range
$collection-&gt;addAttributeToFilter('date_field', array(
    'from' =&gt; '10 September 2010',
    'from' =&gt; '21 September 2010',
    'date' =&gt; true, // specifies conversion of comparison values
    ));

// Add OR condition:
$collection-&gt;addAttributeToFilter(array(
    array(
        'attribute' =&gt; 'field_name',
        'in'        =&gt; array(1, 2, 3),
        ),
    array(
        'attribute' =&gt; 'date_field',
        'from'      =&gt; '2010-09-10',
        ),
    ));
</pre>
<p><strong>Below is the full filter condition codes with attribute code and its sql equivalent</strong></p>
<blockquote><p>
eq	:	=<br />
neq	:	!=<br />
like :	LIKE<br />
nlike :	NOT LIKE<br />
in	:	IN ()<br />
nin	:	NOT IN ()<br />
is	:	IS<br />
notnull :	IS NOT NULL<br />
null :	IS NULL<br />
moreq :	>=<br />
gt	:	><br />
lt	:	<<br />
gteq :	>=<br />
lteq :	<=<br />
finset :	FIND_IN_SET()<br />
from :	>=	 (for use with dates)<br />
to	:	<=	 (for use with dates)<br />
date :	optional flag for use with from/to to specify that comparison value should first be converted to a date<br />
datetime :	optional flag for use with from/to to specify that comparison value should first be converted to a datetime
</p></blockquote>
<p><strong>addFieldToFilter</strong>: alias for addAttributeToFilter(). This filters the database table fields.</p>
<blockquote><p>
/**<br />
* Wrapper for compatibility with Varien_Data_Collection_Db<br />
*<br />
* @param mixed $attribute<br />
* @param mixed $condition<br />
*/<br />
addFieldToFilter($attribute, $condition=null)
</p></blockquote>
<p><strong>addAttributeToSort</strong>: adds ORDER BY clause on $attribute</p>
<blockquote><p>
/**<br />
* Add attribute to sort order<br />
*<br />
* @param string $attribute<br />
* @param string $dir<br />
* @return Mage_Eav_Model_Entity_Collection_Abstract<br />
*/<br />
addAttributeToSort($attribute, $dir=&#8217;asc&#8217;)
</p></blockquote>
<p><strong>addExpressionAttributeToSelect</strong>: adds SQL expression $expression, using $alias, to SELECT clause (typically containing aggregate functions such as SUM(), COUNT()); when $attribute specifies a single attribute as a string, $expression can reference the attribute as simply {{attribute}}, but when passing an array of attributes, each attribute must be referenced in $expression by the name of the specific attribute;</p>
<blockquote><p>
/**<br />
* Add attribute expression (SUM, COUNT, etc)<br />
*<br />
* Example: (&#8216;sub_total&#8217;, &#8216;SUM({{attribute}})&#8217;, &#8216;revenue&#8217;)<br />
* Example: (&#8216;sub_total&#8217;, &#8216;SUM({{revenue}})&#8217;, &#8216;revenue&#8217;)<br />
*<br />
* For some functions like SUM use groupByAttribute.<br />
*<br />
* @param string $alias<br />
* @param string $expression<br />
* @param string $attribute<br />
* @return Mage_Eav_Model_Entity_Collection_Abstract<br />
*/<br />
addExpressionAttributeToSelect($alias, $expression, $attribute)
</p></blockquote>
<p><strong>groupByAttribute</strong>: adds $attribute to GROUP BY clause</p>
<blockquote><p>
/**<br />
* Groups results by specified attribute<br />
*<br />
* @param string|array $attribute<br />
*/<br />
groupByAttribute($attribute)
</p></blockquote>
<p><strong>joinAttribute</strong>: joins another entity and adds attribute from joined entity, using $alias, to SELECT clause.</p>
<p>Here are the parameters for joinAttribute function:-</p>
<p><strong>$alias</strong> = selected field name. You can keep it&#8217;s name whatever you want.</p>
<p><strong>$attribute</strong> = joined entity type code and attribute code = <strong>entity_type_code/attribute_code</strong><br />
<strong>entity_type_code</strong> is present in <strong>eav_entity_type table</strong><br />
<strong>attribute_code</strong> is present in <strong>eav_attribute table</strong><br />
attribute_code is attribute of the corresponding entity you want to select out.</p>
<p><strong>$bind</strong> = attribute code of the main entity to link to the joined entity.</p>
<p><strong>$filter</strong> = primary key for the joined entity (entity_id default)</p>
<blockquote><p>
/**<br />
* Add attribute from joined entity to select<br />
*<br />
* Examples:<br />
* (&#8216;billing_firstname&#8217;, &#8216;customer_address/firstname&#8217;, &#8216;default_billing&#8217;)<br />
* (&#8216;billing_lastname&#8217;, &#8216;customer_address/lastname&#8217;, &#8216;default_billing&#8217;)<br />
* (&#8216;shipping_lastname&#8217;, &#8216;customer_address/lastname&#8217;, &#8216;default_billing&#8217;)<br />
* (&#8216;shipping_postalcode&#8217;, &#8216;customer_address/postalcode&#8217;, &#8216;default_shipping&#8217;)<br />
* (&#8216;shipping_city&#8217;, $cityAttribute, &#8216;default_shipping&#8217;)<br />
*<br />
* Developer is encouraged to use existing instances of attributes and entities<br />
* After first use of string entity name it will be cached in the collection<br />
*<br />
* @todo connect between joined attributes of same entity<br />
* @param string $alias alias for the joined attribute<br />
* @param string|Mage_Eav_Model_Entity_Attribute_Abstract $attribute<br />
* @param string $bind attribute of the main entity to link with joined $filter<br />
* @param string $filter primary key for the joined entity (entity_id default)<br />
* @param string $joinType inner|left<br />
* @return Mage_Eav_Model_Entity_Collection_Abstract<br />
*/<br />
joinAttribute($alias, $attribute, $bind, $filter=null, $joinType=&#8217;inner&#8217;, $storeId=null)
</p></blockquote>
<p><strong>joinTable</strong>: joins table $table</p>
<p>Here are the parameters of the function joinTable:-</p>
<p>$table = table name to join<br />
$bind = ( parent_key = foreign_key )<br />
$fields = array of fields to select<br />
$cond = where condition<br />
$joinType = join type</p>
<blockquote><p>
/**<br />
* Join a table<br />
*<br />
* @param string|array $table<br />
* @param string $bind<br />
* @param string|array $fields<br />
* @param null|array $cond<br />
* @param string $joinType<br />
* @return Mage_Eav_Model_Entity_Collection_Abstract<br />
*/<br />
joinTable($table, $bind, $fields=null, $cond=null, $joinType=&#8217;inner&#8217;)
</p></blockquote>
<p><strong>Using joinAttribute and joinTable</strong></p>
<p>In the code below, all order invoice items are selected, i.e. all products that have been invoiced.<br />
joinTable is used to join sales_order_entity table to fetch increment_id and store_id of the invoice for each product.<br />
joinAttribute is used to fetch order_id, product_name, and store_id.<br />
joinTable is used again to fetch the order status of each invoice item.</p>
<pre class="brush: php; title: ; notranslate">
$collection = Mage::getModel('sales/order_invoice_item')
					-&gt;getCollection()
					-&gt;joinTable('sales_order_entity', 'entity_id=parent_id', array('invoice_id'=&gt;'increment_id', 'store_id' =&gt; 'store_id'), null , 'left')
					-&gt;joinAttribute('order_id', 'invoice/order_id', 'parent_id', null, 'left')
					-&gt;joinAttribute('product_name', 'invoice_item/name', 'entity_id', null, 'left')
					-&gt;joinAttribute('store_id', 'invoice/store_id', 'parent_id', null, 'left')

					-&gt;joinTable('sales_order', 'entity_id=order_id', array('order_status'=&gt;'status'), null , 'left')
					;
</pre>
<p><strong>joinField</strong>: joins regular table field using an attribute as foreign key</p>
<blockquote><p>
/**<br />
* Join regular table field and use an attribute as fk<br />
*<br />
* Examples:<br />
* (&#8216;country_name&#8217;, &#8216;directory/country_name&#8217;, &#8216;name&#8217;, &#8216;country_id=shipping_country&#8217;, &#8220;{{table}}.language_code=&#8217;en&#8217;&#8221;, &#8216;left&#8217;)<br />
*<br />
* @param string $alias &#8216;country_name&#8217;<br />
* @param string $table &#8216;directory/country_name&#8217;<br />
* @param string $field &#8216;name&#8217;<br />
* @param string $bind &#8216;PK(country_id)=FK(shipping_country_id)&#8217;<br />
* @param string|array $cond &#8220;{{table}}.language_code=&#8217;en&#8217;&#8221; OR array(&#8216;language_code&#8217;=&gt;&#8217;en&#8217;)<br />
* @param string $joinType &#8216;left&#8217;<br />
* @return Mage_Eav_Model_Entity_Collection_Abstract<br />
*/<br />
joinField($alias, $table, $field, $bind, $cond=null, $joinType=&#8217;inner&#8217;)
</p></blockquote>
<p><strong>removeAttributeToSelect</strong>: removes $attribute from SELECT clause; specify null to remove all attributes</p>
<blockquote><p>
/**<br />
* Remove an attribute from selection list<br />
*<br />
* @param string $attribute<br />
* @return Mage_Eav_Model_Entity_Collection_Abstract<br />
*/<br />
removeAttributeToSelect($attribute=null)
</p></blockquote>
<p><strong>setPage</strong>: sets LIMIT clause by specifying page number (one-indexed) and number of records per page; equivalent to calling setCurPage($pageNum) and setPageSize($pageSize)</p>
<blockquote><p>
/**<br />
* Set collection page start and records to show<br />
*<br />
* @param integer $pageNum<br />
* @param integer $pageSize<br />
* @return Mage_Eav_Model_Entity_Collection_Abstract<br />
*/<br />
setPage($pageNum, $pageSize)
</p></blockquote>
<p><strong>importFromArray</strong>: imports 2D array into collection as objects</p>
<blockquote><p>
/**<br />
* Import 2D array into collection as objects<br />
*<br />
* If the imported items already exist, update the data for existing objects<br />
*<br />
* @param array $arr<br />
* @return Mage_Eav_Model_Entity_Collection_Abstract<br />
*/<br />
importFromArray($arr)
</p></blockquote>
<p><strong>exportToArray</strong>: returns collection data as a 2D array</p>
<blockquote><p>
/**<br />
* Get collection data as a 2D array<br />
*<br />
* @return array<br />
*/<br />
exportToArray()
</p></blockquote>
<p><strong>setOrder</strong>: alias for addAttributeToSort() q.v., identical except that it can accept array of attributes, and default $dir is desc</p>
<blockquote><p>
/**<br />
* Set sorting order<br />
*<br />
* $attribute can also be an array of attributes<br />
*<br />
* @param string|array $attribute<br />
* @param string $dir<br />
* @return Mage_Eav_Model_Entity_Collection_Abstract<br />
*/<br />
setOrder($attribute, $dir=&#8217;desc&#8217;)
</p></blockquote>
<blockquote><p>Inspired by Magento Wiki:<br />
<a href="http://www.magentocommerce.com/wiki/5_-_modules_and_development/catalog/using_collections_in_magento" rel="nofollow" target="_blank">http://www.magentocommerce.com/wiki/5_-_modules_and_development/catalog/using_collections_in_magento</a>.<br />
However, more of my code, text &#038; understanding are added in this article.
</p></blockquote>
<p>Hope this helps. Thanks.</p>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small><img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=981&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/magento-how-to-filter-product-collection-using-2-or-more-category-filters/' rel='bookmark' title='Permanent Link: Magento: How to filter product collection using 2 or more category filters?'>Magento: How to filter product collection using 2 or more category filters?</a></li>
<li><a href='http://blog.chapagain.com.np/magento-collection-functions/' rel='bookmark' title='Permanent Link: Magento: Very Useful Collection Functions'>Magento: Very Useful Collection Functions</a></li>
<li><a href='http://blog.chapagain.com.np/magento-adding-category-attributes/' rel='bookmark' title='Permanent Link: Magento: Adding category attributes'>Magento: Adding category attributes</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-search-or-filter-by-multiselect-attribute-in-admin-grid/' rel='bookmark' title='Permanent Link: Magento: How to search or filter by multiselect attribute in admin grid?'>Magento: How to search or filter by multiselect attribute in admin grid?</a></li>
<li><a href='http://blog.chapagain.com.np/magento-sort-latest-product-by-created-date-and-new-from-date/' rel='bookmark' title='Permanent Link: Magento: Sort latest product by &#8216;created date&#8217; and &#8216;new from date&#8217;'>Magento: Sort latest product by &#8216;created date&#8217; and &#8216;new from date&#8217;</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/magento-join-filter-select-and-sort-attributes-fields-and-tables/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Magento: Set Random Order in Collection using RAND()</title>
		<link>http://blog.chapagain.com.np/magento-set-random-order-in-collection-using-rand/</link>
		<comments>http://blog.chapagain.com.np/magento-set-random-order-in-collection-using-rand/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 12:09:38 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[collection]]></category>
		<category><![CDATA[order]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[rand]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=845</guid>
		<description><![CDATA[Scenario: You have created a custom module. You have entered certain data in your database. You need to show the data randomly. Solution: In MySQL the rand() function helps the select query to fetch data randomly. In Magento, you can select random rows from MySQL table using Zend_Db_Expr(&#8216;RAND()&#8217;). You have to create a new function [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/generating-random-image/' rel='bookmark' title='Permanent Link: Generating random image'>Generating random image</a></li>
<li><a href='http://blog.chapagain.com.np/random-number-string-generation-in-php/' rel='bookmark' title='Permanent Link: Random number, string generation in PHP'>Random number, string generation in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/magento-collection-functions/' rel='bookmark' title='Permanent Link: Magento: Very Useful Collection Functions'>Magento: Very Useful Collection Functions</a></li>
<li><a href='http://blog.chapagain.com.np/php-generating-random-string/' rel='bookmark' title='Permanent Link: PHP: Generating Multiple Random String'>PHP: Generating Multiple Random String</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-filter-product-collection-using-2-or-more-category-filters/' rel='bookmark' title='Permanent Link: Magento: How to filter product collection using 2 or more category filters?'>Magento: How to filter product collection using 2 or more category filters?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong>Scenario:</strong></p>
<p>You have created a custom module.<br />
You have entered certain data in your database.<br />
You need to show the data randomly.</p>
<p><strong>Solution:</strong></p>
<p><span id="more-845"></span></p>
<p>In MySQL the rand() function helps the select query to fetch data randomly. In Magento, you can select random rows from MySQL table using <strong>Zend_Db_Expr(&#8216;RAND()&#8217;)</strong>.</p>
<p>You have to create a new function in your module&#8217;s collection class <strong>(YourNamespace/YourModule/Model/Mysql4/YourModule/Collection.php)</strong></p>
<pre class="brush: php; title: ; notranslate">
public function setRandomOrder()
{
	$this-&gt;getSelect()-&gt;order(new Zend_Db_Expr('RAND()'));
	return $this;
}
</pre>
<p>Now, you can fetch random data from your table using the above create <strong>setRandomOrder</strong> function. The code below can be kept in the block or template (.phtml) file of your module.</p>
<pre class="brush: php; title: ; notranslate">
$collection = Mage::getModel('yourmodule/yourmodule')
					-&gt;getCollection()
					-&gt;setRandomOrder();

echo &quot;&lt;pre&gt;&quot;; print_r($collection-&gt;getData()); echo &quot;&lt;/pre&gt;&quot;;
</pre>
<p>Hope this helps. Thanks.</p>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small><img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=845&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/generating-random-image/' rel='bookmark' title='Permanent Link: Generating random image'>Generating random image</a></li>
<li><a href='http://blog.chapagain.com.np/random-number-string-generation-in-php/' rel='bookmark' title='Permanent Link: Random number, string generation in PHP'>Random number, string generation in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/magento-collection-functions/' rel='bookmark' title='Permanent Link: Magento: Very Useful Collection Functions'>Magento: Very Useful Collection Functions</a></li>
<li><a href='http://blog.chapagain.com.np/php-generating-random-string/' rel='bookmark' title='Permanent Link: PHP: Generating Multiple Random String'>PHP: Generating Multiple Random String</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-filter-product-collection-using-2-or-more-category-filters/' rel='bookmark' title='Permanent Link: Magento: How to filter product collection using 2 or more category filters?'>Magento: How to filter product collection using 2 or more category filters?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/magento-set-random-order-in-collection-using-rand/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>10 Very Useful SQL Queries with JOINS</title>
		<link>http://blog.chapagain.com.np/very-useful-sql-queries-with-joins/</link>
		<comments>http://blog.chapagain.com.np/very-useful-sql-queries-with-joins/#comments</comments>
		<pubDate>Fri, 14 May 2010 19:30:10 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[join]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[table]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=779</guid>
		<description><![CDATA[The JOIN keyword is used in an SQL statement to query data from two or more tables, based on a relationship between certain columns in these tables. [@via w3schools] A SQL JOIN clause combines records from two or more tables in a database. It creates a set that can be saved as a table or [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/magento-join-filter-select-and-sort-attributes-fields-and-tables/' rel='bookmark' title='Permanent Link: Magento: Join, filter, select and sort attributes, fields and tables'>Magento: Join, filter, select and sort attributes, fields and tables</a></li>
<li><a href='http://blog.chapagain.com.np/alter-mysql-table-to-add-drop-column-add-foreign-key/' rel='bookmark' title='Permanent Link: Alter MySQL table to add &#038; drop column &#038; add Foreign Key'>Alter MySQL table to add &#038; drop column &#038; add Foreign Key</a></li>
<li><a href='http://blog.chapagain.com.np/mysql-database-foreign-key-understanding-and-implementation/' rel='bookmark' title='Permanent Link: MySQL Database: Foreign Key Understanding and Implementation'>MySQL Database: Foreign Key Understanding and Implementation</a></li>
<li><a href='http://blog.chapagain.com.np/fun-with-strings-in-php-part-1/' rel='bookmark' title='Permanent Link: Fun with strings in PHP (Part 1)'>Fun with strings in PHP (Part 1)</a></li>
<li><a href='http://blog.chapagain.com.np/sql-error-cannot-insert-the-value-null-into-column-column-does-not-allow-nulls-insert-fails/' rel='bookmark' title='Permanent Link: SQL Error: Cannot insert the value NULL into column&#8230; column does not allow nulls. INSERT fails.'>SQL Error: Cannot insert the value NULL into column&#8230; column does not allow nulls. INSERT fails.</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<blockquote><p>The JOIN keyword is used in an SQL statement to query data from two or more tables, based on a relationship between certain columns in these tables. [@via w3schools]</p></blockquote>
<blockquote><p>A SQL JOIN clause combines records from two or more tables in a database. It creates a set that can be saved as a table or used as is. A JOIN is a means for combining fields from two tables by using values common to each. ANSI standard SQL specifies four types of JOINs: INNER, OUTER, LEFT, and RIGHT. In special cases, a table (base table, view, or joined table) can JOIN to itself in a self-join. [@via wikipedia]</p></blockquote>
<p><span id="more-779"></span></p>
<p>SQL Joins are helpful when we have to fetch data with a single query from two or more database tables.</p>
<p><strong>Case:</strong></p>
<p>I need to store news/article information. The news can also have comments and tags. News can be submitted/posted by multiple users.</p>
<p>According to the above scenario, I have created 5 tables and inserted some data into them :-</p>
<p><strong>news </strong>- to store news<br />
<strong>comments </strong>- to store comments for any particular news<br />
<strong>tags </strong>- to store tags associated with any particular news<br />
<strong>users </strong>- to store user information<br />
<strong>tags_news</strong> &#8211; to store relationship between news and tags</p>
<p>&#8211;<br />
&#8211; <strong>Table structure for table `comments`</strong><br />
&#8211;<br />
<code><br />
CREATE TABLE `comments` (<br />
  `id` bigint(20) NOT NULL auto_increment,<br />
  `news_id` bigint(20) NOT NULL,<br />
  `user_id` bigint(20) NOT NULL,<br />
  `detail` text NOT NULL,<br />
  `status` tinyint(1) NOT NULL default '1',<br />
  `comment_date` int(11) NOT NULL,<br />
  PRIMARY KEY  (`id`),<br />
  KEY `user_id` (`user_id`),<br />
  KEY `news_id` (`news_id`)<br />
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;<br />
</code></p>
<p>&#8211;<br />
&#8211; <strong>Dumping data for table `comments`</strong><br />
&#8211;<br />
<code><br />
INSERT INTO `comments` (`id`, `news_id`, `user_id`, `detail`, `status`, `comment_date`) VALUES<br />
(1, 1, 2, 'nice post :)', 1, 1273431296),<br />
(2, 2, 2, 'hahaha', 1, 1273431420),<br />
(3, 3, 2, '3123123', 1, 1273431452),<br />
(4, 1, 2, 'thank You', 1, 1273431475),<br />
(5, 2, 1, 'congratulations!', 1, 1273431500);<br />
</code><br />
&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>&#8211;<br />
&#8211; <strong>Table structure for table `news`</strong><br />
&#8211;<br />
<code><br />
CREATE TABLE `news` (<br />
  `id` bigint(20) NOT NULL auto_increment,<br />
  `user_id` bigint(20) NOT NULL,<br />
  `title` text NOT NULL,<br />
  `detail` text NOT NULL,<br />
  `visit` int(11) NOT NULL default '0',<br />
  `status` tinyint(1) NOT NULL default '1',<br />
  `created_date` int(11) NOT NULL,<br />
  PRIMARY KEY  (`id`),<br />
  KEY `user_id` (`user_id`)<br />
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;<br />
</code><br />
&#8211;<br />
&#8211; <strong>Dumping data for table `news`</strong><br />
&#8211;<br />
<code><br />
INSERT INTO `news` (`id`, `user_id`, `title`, `detail`, `visit`, `status`, `created_date`) VALUES<br />
(1, 1, 'Extra Content', 'fasdfasdf', 2, 1, 1273431296),<br />
(2, 1, 'My My Question', 'this is jpt question.. :D', 16, 1, 1273431389),<br />
(3, 2, 'Am I ram?', 'I am ram..yahoo !!', 3, 1, 1273431420);<br />
</code><br />
&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>&#8211;<br />
&#8211; <strong>Table structure for table `tags`</strong><br />
&#8211;<br />
<code><br />
CREATE TABLE `tags` (<br />
  `id` bigint(20) NOT NULL auto_increment,<br />
  `name` varchar(255) NOT NULL,<br />
  `slug` varchar(255) NOT NULL,<br />
  PRIMARY KEY  (`id`)<br />
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;<br />
</code><br />
&#8211;<br />
&#8211; <strong>Dumping data for table `tags`</strong><br />
&#8211;<br />
<code><br />
INSERT INTO `tags` (`id`, `name`, `slug`) VALUES<br />
(1, 'sagarmatha', 'sagarmatha'),<br />
(2, 'nepal', 'nepal'),<br />
(3, 'gautam buddha', 'gautam-buddha'),<br />
(4, 'testing', 'testing'),<br />
(5, 'tags', 'tags'),<br />
(6, 'tasty apple', 'tasty-apple'),<br />
(7, 'banana', 'banana');<br />
</code><br />
&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>&#8211;<br />
&#8211; <strong>Table structure for table `tags_news`</strong><br />
&#8211;<br />
<code><br />
CREATE TABLE `tags_news` (<br />
  `id` bigint(20) NOT NULL auto_increment,<br />
  `news_id` bigint(20) NOT NULL,<br />
  `tags_id` bigint(20) NOT NULL,<br />
  PRIMARY KEY  (`id`),<br />
  KEY `news_id` (`news_id`)<br />
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;<br />
</code><br />
&#8211;<br />
&#8211; <strong>Dumping data for table `tags_news`</strong><br />
&#8211;<br />
<code><br />
INSERT INTO `tags_news` (`id`, `news_id`, `tags_id`) VALUES<br />
(1, 1, 1),<br />
(2, 1, 2),<br />
(3, 1, 3),<br />
(4, 2, 4),<br />
(5, 2, 5),<br />
(6, 2, 6),<br />
(7, 3, 6),<br />
(8, 3, 7);<br />
</code><br />
&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>&#8211;<br />
&#8211; <strong>Table structure for table `users`</strong><br />
&#8211;<br />
<code><br />
CREATE TABLE `users` (<br />
  `id` bigint(20) NOT NULL auto_increment,<br />
  `user_id` bigint(20) NOT NULL,<br />
  `firstname` varchar(100) NOT NULL,<br />
  `lastname` varchar(100) NOT NULL,<br />
  PRIMARY KEY  (`id`),<br />
  KEY `user_id` (`user_id`)<br />
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;<br />
</code><br />
&#8211;<br />
&#8211; <strong>Dumping data for table `users`</strong><br />
&#8211;<br />
<code><br />
INSERT INTO `users` (`id`, `user_id`, `firstname`, `lastname`) VALUES<br />
(1, 1, 'Mukesh', 'Chapagain'),<br />
(2, 2, 'Christopher', 'Gayle'),<br />
(3, 3, 'Brian', 'Lara');<br />
</code><br />
&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Now, by using SQL JOINS, I can fetch data from these tables for different conditions and in different ways. Here follows the different SQL Queries with the magical JOIN statements:-</p>
<p><strong>1) SELECT NEWS WITH COMMENTS COUNT FOR EACH NEWS</strong></p>
<p><code><br />
SELECT n.*, ifnull(c.count,0) AS comment FROM news AS n<br />
	LEFT JOIN<br />
		(SELECT COUNT(comments.id) AS count, comments.news_id FROM comments GROUP BY comments.news_id) AS c<br />
			ON n.id = c.news_id<br />
				ORDER BY n.created_date DESC;<br />
</code>		</p>
<p><strong>2) SELECT NEWS POSTED BY ANY PARTICULAR USER (HERE, user_id = 1)</strong></p>
<p><code><br />
SELECT n.* FROM news AS n<br />
	INNER JOIN<br />
		users AS u<br />
			ON n.user_id = u.id<br />
				WHERE u.id = 1;<br />
</code></p>
<p><strong>3) SELECT NEWS POSTED BY ANY PARTICULAR USER (WITH USER&#8217;S FIRSTNAME AND LASTNAME) (HERE, user_id = 1)</strong></p>
<p><code><br />
SELECT n.*, u.firstname AS firstname, u.lastname AS lastname FROM news AS n<br />
	INNER JOIN<br />
		users AS u<br />
			ON n.user_id = u.id<br />
				WHERE u.id = 1;<br />
</code>			</p>
<p><strong>4) SELECT NEWS POSTED BY ANY PARTICULAR USER (WITH COMMENTS COUNT FOR EACH NEWS) (HERE, user_id = 1)</strong></p>
<p><code><br />
SELECT n.*, ifnull(c.count,0) AS comment, u.firstname AS firstname, u.lastname AS lastname FROM news AS n<br />
	LEFT JOIN<br />
		(SELECT COUNT(comments.id) AS count, comments.news_id FROM comments GROUP BY comments.news_id) AS c<br />
			ON n.id = c.news_id<br />
				INNER JOIN<br />
					users AS u<br />
						ON n.user_id = u.id<br />
							WHERE u.id = 1;<br />
</code></p>
<p><strong>5) SELECT COMMENTS FOR ANY PARTICULAR NEWS (HERE, news_id =1)</strong></p>
<p><code><br />
SELECT c.* FROM comments AS c<br />
	INNER JOIN<br />
		news AS n<br />
			ON c.news_id = n.id<br />
				WHERE c.news_id = 1;<br />
</code></p>
<p><strong>6) SELECT COMMENTS FOR ANY PARTICULAR NEWS (ALONG WITH USER INFORMATION) (HERE, news_id = 1)</strong></p>
<p><code><br />
SELECT c.*, u.firstname AS firstname, u.lastname AS lastname FROM comments AS c<br />
	INNER JOIN<br />
		news AS n<br />
			ON c.news_id = n.id<br />
				INNER JOIN<br />
					users AS u<br />
						ON c.user_id = u.id<br />
							WHERE c.news_id = 1;<br />
</code></p>
<p><strong>7) SELECT TAGS FOR ANY PARTICULAR NEWS (HERE, news_id = 1)</strong>	</p>
<p><code><br />
SELECT t.* FROM tags AS t<br />
	INNER JOIN<br />
		(SELECT tags_news.news_id AS news_id, tags_news.tags_id FROM tags_news WHERE tags_news.news_id = 1) AS tn<br />
			ON t.id = tn.tags_id;<br />
</code>			</p>
<p><strong>8) SELECT NEWS BY TAG NAME (HERE, tag = &#8216;nepal&#8217;)</strong></p>
<p><code><br />
SELECT n.*, t.name AS tag_name, t.slug AS tag_slug FROM news AS n<br />
	INNER JOIN<br />
		tags_news as tn<br />
			ON n.id = tn.news_id<br />
				INNER JOIN tags AS t<br />
					ON tn.tags_id = t.id<br />
						WHERE t.slug = 'nepal';<br />
</code>			</p>
<p><strong>9) SELECT NEWS BY TAG NAME (ALONG WITH COMMENTS COUNT) (HERE, tag = &#8216;nepal&#8217;)	</strong>		</p>
<p><code><br />
SELECT n.*, ifnull(c.count,0) AS comment, t.name AS tag_name, t.slug AS tag_slug, t.id AS tag_id FROM news AS n<br />
	INNER JOIN<br />
		tags_news AS tn<br />
			ON (n.id = tn.news_id)<br />
				INNER JOIN tags AS t<br />
					ON (tn.tags_id = t.id)<br />
						LEFT JOIN<br />
							(SELECT COUNT(comments.id) AS count, comments.news_id FROM comments<br />
								GROUP BY comments.news_id) AS c<br />
									ON n.id = c.news_id<br />
										WHERE t.slug = 'nepal'<br />
											ORDER BY n.created_date DESC;<br />
</code></p>
<p><strong>10) SELECT TAG CLOUD</strong>		</p>
<p><code><br />
SELECT t . * , IFNULL( tq.count, 0 ) AS count<br />
	FROM tags AS t<br />
		LEFT JOIN (<br />
			SELECT COUNT( tags_news.id ) AS count, tags_news.tags_id<br />
				FROM tags_news<br />
					GROUP BY tags_news.tags_id<br />
						) AS tq ON t.id = tq.tags_id<br />
							ORDER BY t.name ASC<br />
								LIMIT 15;<br />
</code><br />
Hope this helps. And thanks for reading.  </p>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small><img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=779&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/magento-join-filter-select-and-sort-attributes-fields-and-tables/' rel='bookmark' title='Permanent Link: Magento: Join, filter, select and sort attributes, fields and tables'>Magento: Join, filter, select and sort attributes, fields and tables</a></li>
<li><a href='http://blog.chapagain.com.np/alter-mysql-table-to-add-drop-column-add-foreign-key/' rel='bookmark' title='Permanent Link: Alter MySQL table to add &#038; drop column &#038; add Foreign Key'>Alter MySQL table to add &#038; drop column &#038; add Foreign Key</a></li>
<li><a href='http://blog.chapagain.com.np/mysql-database-foreign-key-understanding-and-implementation/' rel='bookmark' title='Permanent Link: MySQL Database: Foreign Key Understanding and Implementation'>MySQL Database: Foreign Key Understanding and Implementation</a></li>
<li><a href='http://blog.chapagain.com.np/fun-with-strings-in-php-part-1/' rel='bookmark' title='Permanent Link: Fun with strings in PHP (Part 1)'>Fun with strings in PHP (Part 1)</a></li>
<li><a href='http://blog.chapagain.com.np/sql-error-cannot-insert-the-value-null-into-column-column-does-not-allow-nulls-insert-fails/' rel='bookmark' title='Permanent Link: SQL Error: Cannot insert the value NULL into column&#8230; column does not allow nulls. INSERT fails.'>SQL Error: Cannot insert the value NULL into column&#8230; column does not allow nulls. INSERT fails.</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/very-useful-sql-queries-with-joins/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SQL Error: Cannot insert the value NULL into column&#8230; column does not allow nulls. INSERT fails.</title>
		<link>http://blog.chapagain.com.np/sql-error-cannot-insert-the-value-null-into-column-column-does-not-allow-nulls-insert-fails/</link>
		<comments>http://blog.chapagain.com.np/sql-error-cannot-insert-the-value-null-into-column-column-does-not-allow-nulls-insert-fails/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 11:20:19 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[ms-sql]]></category>
		<category><![CDATA[problem]]></category>
		<category><![CDATA[query]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=107</guid>
		<description><![CDATA[Error description: Cannot insert the value NULL into column &#8216;SourceId&#8217;, table &#8216;Advisory.dbo.AdvDocSource&#8217;; column does not allow nulls. INSERT fails. The statement has been terminated. The &#8216;CompanyAdd&#8217; procedure attempted to return a status of NULL, which is not allowed. A status of 0 will be returned instead. &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- This error occurs because the &#8216;SourceId&#8217; column in [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/alter-mysql-table-to-add-drop-column-add-foreign-key/' rel='bookmark' title='Permanent Link: Alter MySQL table to add &#038; drop column &#038; add Foreign Key'>Alter MySQL table to add &#038; drop column &#038; add Foreign Key</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-select-insert-update-and-delete-data/' rel='bookmark' title='Permanent Link: Magento: How to select, insert, update, and delete data?'>Magento: How to select, insert, update, and delete data?</a></li>
<li><a href='http://blog.chapagain.com.np/very-useful-sql-queries-with-joins/' rel='bookmark' title='Permanent Link: 10 Very Useful SQL Queries with JOINS'>10 Very Useful SQL Queries with JOINS</a></li>
<li><a href='http://blog.chapagain.com.np/mysql-database-foreign-key-understanding-and-implementation/' rel='bookmark' title='Permanent Link: MySQL Database: Foreign Key Understanding and Implementation'>MySQL Database: Foreign Key Understanding and Implementation</a></li>
<li><a href='http://blog.chapagain.com.np/displaying-all-products-and-new-products-listing-in-columngrid-layout-zen-cart/' rel='bookmark' title='Permanent Link: Displaying all products and new products listing in column/grid layout &#8211; Zen-cart'>Displaying all products and new products listing in column/grid layout &#8211; Zen-cart</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Error description:</p>
<p style="text-align: justify;">Cannot insert the value NULL into column &#8216;SourceId&#8217;, table &#8216;Advisory.dbo.AdvDocSource&#8217;; column does not allow nulls. INSERT fails.<br />
The statement has been terminated. The &#8216;CompanyAdd&#8217; procedure attempted to return a status of NULL, which is not allowed. A status of 0 will be returned instead.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p style="text-align: justify;">This error occurs because the &#8216;SourceId&#8217; column in my table is primary key and it is set to not null. i.e. it doesn&#8217;t allow null entries. And I have not made it auto increment.</p>
<p><span id="more-107"></span></p>
<p>For making a table column auto increment:<br />
- Go to server explorer.<br />
- In Column Properties, go to Identity Specification.<br />
- Go to (Is Identity) and make it &#8216;Yes&#8217; from the selection list.</p>
<p>You are done. You also have the option for Identity Increment and Identity Seed.</p>
<p>The SQL Query is:<br />
CREATE TABLE [yourTableName](SourceID int IDENTITY(1,1) NOT NULL, &#8230;</p>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small><img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=107&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/alter-mysql-table-to-add-drop-column-add-foreign-key/' rel='bookmark' title='Permanent Link: Alter MySQL table to add &#038; drop column &#038; add Foreign Key'>Alter MySQL table to add &#038; drop column &#038; add Foreign Key</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-select-insert-update-and-delete-data/' rel='bookmark' title='Permanent Link: Magento: How to select, insert, update, and delete data?'>Magento: How to select, insert, update, and delete data?</a></li>
<li><a href='http://blog.chapagain.com.np/very-useful-sql-queries-with-joins/' rel='bookmark' title='Permanent Link: 10 Very Useful SQL Queries with JOINS'>10 Very Useful SQL Queries with JOINS</a></li>
<li><a href='http://blog.chapagain.com.np/mysql-database-foreign-key-understanding-and-implementation/' rel='bookmark' title='Permanent Link: MySQL Database: Foreign Key Understanding and Implementation'>MySQL Database: Foreign Key Understanding and Implementation</a></li>
<li><a href='http://blog.chapagain.com.np/displaying-all-products-and-new-products-listing-in-columngrid-layout-zen-cart/' rel='bookmark' title='Permanent Link: Displaying all products and new products listing in column/grid layout &#8211; Zen-cart'>Displaying all products and new products listing in column/grid layout &#8211; Zen-cart</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/sql-error-cannot-insert-the-value-null-into-column-column-does-not-allow-nulls-insert-fails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
