<?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; MySQL</title>
	<atom:link href="http://blog.chapagain.com.np/category/mysql/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>Alter MySQL table to add &amp; drop column &amp; add Foreign Key</title>
		<link>http://blog.chapagain.com.np/alter-mysql-table-to-add-drop-column-add-foreign-key/</link>
		<comments>http://blog.chapagain.com.np/alter-mysql-table-to-add-drop-column-add-foreign-key/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 00:54:41 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[alter table]]></category>
		<category><![CDATA[foreign key]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=1576</guid>
		<description><![CDATA[This article shows:- - How to add column to mysql database table after the table has already been created - How to delete column from mysql database table after the table has already been created - How to add foreign key to table column after the table has already been created Basically, all this can [...]


<strong>Related posts:</strong><ol><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/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>
<li><a href='http://blog.chapagain.com.np/backup-and-recovery-of-mysql-database/' rel='bookmark' title='Permanent Link: Backup and Recovery of MySQL database'>Backup and Recovery of MySQL database</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/magento-upgrading-mysql-setup-of-a-module/' rel='bookmark' title='Permanent Link: Magento: Upgrading mysql setup of a module'>Magento: Upgrading mysql setup of a module</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>This article shows:-</p>
<blockquote><p>
- How to add column to mysql database table after the table has already been created</p>
<p>- How to delete column from mysql database table after the table has already been created</p>
<p><span id="more-1576"></span></p>
<p>- How to add foreign key to table column after the table has already been created
</p></blockquote>
<p>Basically, all this can be done by &#8216;<strong>ALTER TABLE</strong>&#8216; statement. Here is an step-by-step tutorial on how we do it.</p>
<p><strong>Create parent table</strong><br />
<code><br />
CREATE TABLE IF NOT EXISTS parent(<br />
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,<br />
name VARCHAR(255) NOT NULL,<br />
description TEXT DEFAULT NULL,<br />
status TINYINT(1) NOT NULL,<br />
PRIMARY KEY(id)<br />
);<br />
</code></p>
<p><strong>Create child table</strong><br />
<code><br />
CREATE TABLE IF NOT EXISTS child(<br />
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,<br />
name VARCHAR(255) NOT NULL,<br />
description TEXT DEFAULT NULL,<br />
PRIMARY KEY(id)<br />
);<br />
</code></p>
<p>After we create both parent and child table, we remember that:- </p>
<blockquote><p>
- We have added an extra unnecessary column in parent table.<br />
- We have missed adding a column to child table.<br />
- And this column in child table should be the foreign key for the parent table.
</p></blockquote>
<p>So, our step would be:-</p>
<p><strong>First of all, delete the unncessary column from parent table</strong></p>
<p><code>ALTER TABLE parent DROP status;</code></p>
<p><strong>Secondly, add a new column in child table</strong></p>
<p><code>ALTER TABLE child ADD parent_id int(11);</code></p>
<p><strong>Finally, add foreign key contraint to the child table which relates to the parent table&#8217;s column (primary key)</strong></p>
<p><code>ALTER TABLE child ADD CONSTRAINT child_FK_1<br />
	FOREIGN KEY (parent_id) REFERENCES parent (id)<br />
	ON DELETE CASCADE;</code></p>
<p>More detail on MySQL foreign key and its implementation can be found on: <a href="http://blog.chapagain.com.np/mysql-database-foreign-key-understanding-and-implementation/" target="_blank">MySQL Database: Foreign Key Understanding and Implementation</a></p>
<p>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=1576&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><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/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>
<li><a href='http://blog.chapagain.com.np/backup-and-recovery-of-mysql-database/' rel='bookmark' title='Permanent Link: Backup and Recovery of MySQL database'>Backup and Recovery of MySQL database</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/magento-upgrading-mysql-setup-of-a-module/' rel='bookmark' title='Permanent Link: Magento: Upgrading mysql setup of a module'>Magento: Upgrading mysql setup of a module</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/alter-mysql-table-to-add-drop-column-add-foreign-key/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Database: Foreign Key Understanding and Implementation</title>
		<link>http://blog.chapagain.com.np/mysql-database-foreign-key-understanding-and-implementation/</link>
		<comments>http://blog.chapagain.com.np/mysql-database-foreign-key-understanding-and-implementation/#comments</comments>
		<pubDate>Mon, 18 Jul 2011 02:22:52 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[cascade]]></category>
		<category><![CDATA[foreign key]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=1262</guid>
		<description><![CDATA[Some definitions of foreign key:- A FOREIGN KEY in one table points to a PRIMARY KEY in another table. A foreign key is a field in a relational table that matches the primary key of another table. The foreign key can be used to cross-reference tables. A table may have multiple foreign keys, and each [...]


<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/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/backup-and-recovery-of-mysql-database/' rel='bookmark' title='Permanent Link: Backup and Recovery of MySQL database'>Backup and Recovery of MySQL database</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>
<li><a href='http://blog.chapagain.com.np/magento-how-to-delete-system-attribute/' rel='bookmark' title='Permanent Link: Magento: How to delete System Attribute?'>Magento: How to delete System Attribute?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Some definitions of foreign key:-</p>
<blockquote><p>A FOREIGN KEY in one table points to a PRIMARY KEY in another table.</p>
<p>A foreign key is a field in a relational table that matches the primary key of another table. The foreign key can be used to cross-reference tables. A table may have multiple foreign keys, and each foreign key can have a different referenced table.</p>
<p><span id="more-1262"></span></p>
<p>A Foreign Key is a Referential Constraint between two tables. A Referential Constraint or Referential Integrity is a property of data which, when satisfied, requires every value of one attribute (column) of a relation (table) to exist as a value of another attribute in a different (or the same) relation (table).
</p></blockquote>
<p>For MySQL, to support foreign key, the table type should be &#8216;<strong>InnoDB</strong>&#8216;. Therefore, when we are cross-referencing two tables through foreign key, both the tables must be InnoDB tables and they must not be Temporary tables.</p>
<p><strong>InnoDB </strong> also supports foreign key references within a table. The referencing and referenced table may be the same table, i.e. the foreign key refers back to the same table. Such a foreign key is known as a self-referencing or recursive foreign key.</p>
<p>When the user attempts to delete or update a row from a parent table, and there are one or more matching rows in the child table, InnoDB handles this through &#8220;<strong>Referential Action</strong>&#8220;. There are five options regarding the action to be taken. If <strong>ON DELETE</strong> or <strong>ON UPDATE</strong> are not specified, the default action is <strong>RESTRICT</strong>.</p>
<blockquote><p>
<strong>CASCADE</strong>: Delete or update the row from the parent table and automatically delete or update the matching rows in the child table. Both ON DELETE CASCADE and ON UPDATE CASCADE are supported. </p>
<p><strong>SET NULL</strong>: Delete or update the row from the parent table and set the foreign key column or columns in the child table to NULL. This is valid only if the foreign key columns do not have the NOT NULL qualifier specified. Both ON DELETE SET NULL and ON UPDATE SET NULL clauses are supported.</p>
<p><strong>NO ACTION</strong>: In standard SQL, NO ACTION means no action in the sense that an attempt to delete or update a primary key value is not permitted to proceed if there is a related foreign key value in the referenced table. InnoDB rejects the delete or update operation for the parent table.</p>
<p><strong>RESTRICT</strong>: Rejects the delete or update operation for the parent table. Specifying RESTRICT (or NO ACTION) is the same as omitting the ON DELETE or ON UPDATE clause. The main difference between NO ACTION and RESTRICT is that with NO ACTION the referential integrity check is done after trying to alter the table. RESTRICT does the check before trying to execute the UPDATE or DELETE statement. However, in MySQL, foreign key constraints are checked immediately, so NO ACTION is the same as RESTRICT.</p>
<p><strong>SET DEFAULT</strong>: Similar to SET NULL, the foreign key values in the referencing row are set to the column default when the referenced row is updated or deleted. This action is recognized by the parser, but InnoDB rejects table definitions containing ON DELETE SET DEFAULT or ON UPDATE SET DEFAULT clauses.
</p></blockquote>
<p>Here, I will be implementing the foreign key <strong>CASCADE </strong>update and delete.</p>
<p><strong>CASCADE</strong>:-</p>
<p>Whenever rows in the master (referenced) table are deleted, the respective rows of the child (referencing) table with a matching foreign key column will get deleted as well. This is called a cascade delete.</p>
<p>Example Tables: test_customer(customer_id, name, address) and test_order(order_id, customer_id, status)</p>
<p>test_customer is the master table and test_order is the child table, where &#8216;customer_id&#8217; is the foreign key in test_order and represents the customer who placed the order. When a row of test_customer is deleted, any test_order row matching the deleted test_customer&#8217;s customer_id will also be deleted.</p>
<p><strong>Create Tables</strong></p>
<p><code>CREATE TABLE test_customer (<br />
    customer_id int(10) unsigned NOT NULL auto_increment,<br />
    name varchar(100),<br />
    address varchar(100),<br />
    PRIMARY KEY (customer_id)<br />
) ENGINE=InnoDB;</p>
<p>CREATE TABLE test_order (<br />
    order_id int(10) unsigned NOT NULL auto_increment,<br />
    customer_id int(10) unsigned NOT NULL,<br />
    status varchar(30),<br />
    PRIMARY KEY (order_id)<br />
) ENGINE=InnoDB; </code></p>
<p><strong>Add Foreign Key</strong></p>
<p><code>ALTER TABLE test_order<br />
ADD CONSTRAINT FK_test_order<br />
FOREIGN KEY (customer_id) REFERENCES test_customer(customer_id)<br />
ON UPDATE CASCADE<br />
ON DELETE CASCADE; </code></p>
<p><strong>Alternative way</strong></p>
<p>Alternatively we can directly add Foreign Key at the time of table creation. You may choose any one way (the following way or the way above) for creating tables and assigning foreign key.</p>
<p><code>SET foreign_key_checks = 0;</p>
<p>CREATE TABLE test_customer (<br />
    customer_id int(10) unsigned NOT NULL auto_increment,<br />
    name varchar(100),<br />
    address varchar(100),<br />
    PRIMARY KEY (customer_id)<br />
) ENGINE=InnoDB;</p>
<p>CREATE TABLE test_order (<br />
    order_id int(10) unsigned NOT NULL auto_increment,<br />
    customer_id int(10) unsigned NOT NULL,<br />
    status varchar(30),<br />
    PRIMARY KEY (order_id),<br />
	CONSTRAINT FK_test_order<br />
	FOREIGN KEY (customer_id) REFERENCES test_customer(customer_id)<br />
	ON UPDATE CASCADE ON DELETE CASCADE<br />
) ENGINE=InnoDB; </p>
<p>SET foreign_key_checks = 1;</code></p>
<p><strong>Insert sample data to test_customer and test_order tables</strong></p>
<p><code>INSERT INTO  test_customer<br />
(  customer_id ,  name ,  address )<br />
VALUES<br />
( '1',  'John',  'New York' ),<br />
( '2',  'Tom',  'London' );</p>
<p>INSERT INTO  test_order<br />
(  order_id ,  customer_id ,  status )<br />
VALUES<br />
( '1',  '1',  'pending' ),<br />
( '2',  '1',  'processing' ),<br />
( '3',  '2',  'complete' ),<br />
( '4',  '2',  'pending' );</code></p>
<p><strong>Doing UPDATE CASCADE</strong></p>
<p>When we update customer_id in test_customer (parent table), the customer_id field in test_order (child table) will also get updated.</p>
<p><code>UPDATE test_customer SET customer_id = 3 WHERE customer_id = 1;</code></p>
<p><strong>Note</strong>:- </p>
<p>We <strong>CANNOT </strong>directly update the foreign key in child table. </p>
<p>Doing this will result in error saying &#8220;<em>Cannot add or update a child row: a foreign key constraint fails</em>&#8220;.</p>
<p><code>UPDATE test_order SET customer_id = 4 WHERE customer_id = 3;</code></p>
<p><strong>Doing DELETE CASCADE</strong></p>
<p>When we delete customer_id in test_customer (parent table), the customer_id field in test_order (child table) will also get deleted.</p>
<p><code>DELETE FROM test_customer WHERE customer_id = 2;</code></p>
<p><strong>Note</strong>:-</p>
<p>We <strong>CAN </strong>directly delete rows from test_order (child table) like below:-</p>
<p><code>DELETE FROM test_order WHERE customer_id = 3;</code></p>
<p>Hope this helps. Thanks</p>
<p><strong>References</strong>:-<br />
1. <a href="http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html"target="_blank" rel="nofollow" >http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html</a><br />
2. <a href="http://en.wikipedia.org/wiki/Foreign_key"target="_blank" rel="nofollow" >http://en.wikipedia.org/wiki/Foreign_key</a></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=1262&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/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/backup-and-recovery-of-mysql-database/' rel='bookmark' title='Permanent Link: Backup and Recovery of MySQL database'>Backup and Recovery of MySQL database</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>
<li><a href='http://blog.chapagain.com.np/magento-how-to-delete-system-attribute/' rel='bookmark' title='Permanent Link: Magento: How to delete System Attribute?'>Magento: How to delete System Attribute?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/mysql-database-foreign-key-understanding-and-implementation/feed/</wfw:commentRss>
		<slash:comments>3</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>Magento: How to filter product collection using 2 or more category filters?</title>
		<link>http://blog.chapagain.com.np/magento-how-to-filter-product-collection-using-2-or-more-category-filters/</link>
		<comments>http://blog.chapagain.com.np/magento-how-to-filter-product-collection-using-2-or-more-category-filters/#comments</comments>
		<pubDate>Thu, 31 Dec 2009 12:44:51 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[category]]></category>
		<category><![CDATA[collection]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[find_in_set]]></category>
		<category><![CDATA[product]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=475</guid>
		<description><![CDATA[Suppose, you have a product collection and you want to filter it by category. Suppose, you want to filter it by more than one category. You can use addCategoryFilter if you have only one category. But, what if you want to filter by more than one category? Category ids are stored for product in a [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/magento-get-category-name-and-url-from-product/' rel='bookmark' title='Permanent Link: Magento: Get category name and url from product'>Magento: Get category name and url from product</a></li>
<li><a href='http://blog.chapagain.com.np/magento-get-sub-categories-and-product-count/' rel='bookmark' title='Permanent Link: Magento: Get sub categories and product count'>Magento: Get sub categories and product count</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-1-4-no-products-displayed-in-category-listing/' rel='bookmark' title='Permanent Link: Magento 1.4: No products displayed in category listing'>Magento 1.4: No products displayed in category listing</a></li>
<li><a href='http://blog.chapagain.com.np/magento-get-product-collection-by-type/' rel='bookmark' title='Permanent Link: Magento: Get Product Collection by Type'>Magento: Get Product Collection by Type</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Suppose, you have a product collection and you want to filter it by category. Suppose, you want to filter it by more than one category. You can use addCategoryFilter if you have only one category. But, what if you want to filter by more than one category?</p>
<p>Category ids are stored for product in a comma separated way. So, to filter product collection by more than one category, you have to use:<br />
<strong>addAttributeToFilter(&#8216;category_ids&#8217;,array(&#8216;finset&#8217;=>$categoryIds));</strong></p>
<p><span id="more-475"></span></p>
<p><strong>$categoryIds</strong> can be a single category id or comma separated category ids.</p>
<p>The following code filters product collection by two category ids (36 and 37).</p>
<pre class="brush: php; title: ; notranslate">
 $_productCollection = Mage::getResourceModel('reports/product_collection')
    -&gt;addAttributeToSelect('*')
    -&gt;addAttributeToFilter('category_ids',array('finset'=&gt;'36,37'));
</pre>
<p>finset does so&#8230; when we use finset, the mysql function <strong>find_in_set</strong> is used in the sql query by Magento.</p>
<p>mysql function find_in_set:</p>
<p><strong>FIND_IN_SET()</strong> looks for the first occurrence of a string within another string containing comma-separated values.</p>
<p>SELECT FIND_IN_SET(&#8216;b&#8217;,'a,b,c,d&#8217;);  // result = 2</p>
<p>Cheers!</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=475&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/magento-get-category-name-and-url-from-product/' rel='bookmark' title='Permanent Link: Magento: Get category name and url from product'>Magento: Get category name and url from product</a></li>
<li><a href='http://blog.chapagain.com.np/magento-get-sub-categories-and-product-count/' rel='bookmark' title='Permanent Link: Magento: Get sub categories and product count'>Magento: Get sub categories and product count</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-1-4-no-products-displayed-in-category-listing/' rel='bookmark' title='Permanent Link: Magento 1.4: No products displayed in category listing'>Magento 1.4: No products displayed in category listing</a></li>
<li><a href='http://blog.chapagain.com.np/magento-get-product-collection-by-type/' rel='bookmark' title='Permanent Link: Magento: Get Product Collection by Type'>Magento: Get Product Collection by Type</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/magento-how-to-filter-product-collection-using-2-or-more-category-filters/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Very simple add, edit, delete, display in PHP</title>
		<link>http://blog.chapagain.com.np/very-simple-add-edit-delete-display-in-php/</link>
		<comments>http://blog.chapagain.com.np/very-simple-add-edit-delete-display-in-php/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 08:03:11 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[add]]></category>
		<category><![CDATA[delete]]></category>
		<category><![CDATA[display]]></category>
		<category><![CDATA[edit]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[register]]></category>
		<category><![CDATA[session]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/2008/03/05/very-simple-add-edit-delete-display-in-php/</guid>
		<description><![CDATA[Before I had posted an article to add, edit, delete, and display contents. I had also included sessions there. There was the facility to login and register users too. But i got feedback that it was a bit complex for novice users of PHP (users who have just started PHPing). It was a kind of [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/add-edit-delete-login-register-in-php-a-simple-and-complete-tutorial/' rel='bookmark' title='Permanent Link: Add, edit, delete, login, register in PHP :: A simple and complete tutorial'>Add, edit, delete, login, register in PHP :: A simple and complete tutorial</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-delete-system-attribute/' rel='bookmark' title='Permanent Link: Magento: How to delete System Attribute?'>Magento: How to delete System Attribute?</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/magento-how-to-delete-remove-extension-from-magentoconnect/' rel='bookmark' title='Permanent Link: Magento: How to delete / remove extension from MagentoConnect?'>Magento: How to delete / remove extension from MagentoConnect?</a></li>
<li><a href='http://blog.chapagain.com.np/session-handling-in-php/' rel='bookmark' title='Permanent Link: Session Handling in PHP'>Session Handling in PHP</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Before I had posted an article to <a href="http://blog.chapagain.com.np/2007/12/08/add-edit-delete-login-register-in-php-a-simple-and-complete-tutorial/">add, edit, delete, and display contents</a>. I had also included sessions there. There was the facility to login and register users too.</p>
<p>But i got feedback that it was a bit complex for novice users of PHP (users who have just started PHPing). It was a kind of full-fledge system with PHP, MySQL and session.</p>
<p><span id="more-44"></span></p>
<p>So in this article, I have simplified the same functionality of the above tutorial. I have not used session in this case. If you want tutorial about session, login, and register then you can refer to my previous article (the link which is provided above).</p>
<p><strong>Files included in this tutorial/code:</strong></p>
<p>users.sql = This contains sql queries to make MySQL database and table</p>
<p>config.php = contains the database connection code (this file is included in all the php pages with the include() function)</p>
<p>index.php = contains the display part (displaying data from database)</p>
<p>add.html = contains form to add data</p>
<p>add.php = contains php code to add data</p>
<p>edit.php = contains php code to edit data</p>
<p>delete.php = contains php code to delete data</p>
<p><strong>Download full source code: <a href="http://chapagain.googlecode.com/files/crud-simple.zip" rel="nofollow"  title="Create, read, update, delete in php and mysql">Create, read, update, delete in php and mysql</a></strong></p>
<p>Cheers,</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=44&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/add-edit-delete-login-register-in-php-a-simple-and-complete-tutorial/' rel='bookmark' title='Permanent Link: Add, edit, delete, login, register in PHP :: A simple and complete tutorial'>Add, edit, delete, login, register in PHP :: A simple and complete tutorial</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-delete-system-attribute/' rel='bookmark' title='Permanent Link: Magento: How to delete System Attribute?'>Magento: How to delete System Attribute?</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/magento-how-to-delete-remove-extension-from-magentoconnect/' rel='bookmark' title='Permanent Link: Magento: How to delete / remove extension from MagentoConnect?'>Magento: How to delete / remove extension from MagentoConnect?</a></li>
<li><a href='http://blog.chapagain.com.np/session-handling-in-php/' rel='bookmark' title='Permanent Link: Session Handling in PHP'>Session Handling in PHP</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/very-simple-add-edit-delete-display-in-php/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Fun with strings in PHP (Part 1)</title>
		<link>http://blog.chapagain.com.np/fun-with-strings-in-php-part-1/</link>
		<comments>http://blog.chapagain.com.np/fun-with-strings-in-php-part-1/#comments</comments>
		<pubDate>Sun, 09 Dec 2007 04:48:39 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[concatenate]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/2007/12/09/fun-with-strings-in-php-part-1/</guid>
		<description><![CDATA[Problem: Concatenate and fetch data from two fields of database and then break it again. Solution: Posted below. The description is included in the code. You have to make a mysql database. The database part is as under: PHP code below: I have not used any loop (for, while, foreach, etc.) here to make the [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/session-handling-in-php/' rel='bookmark' title='Permanent Link: Session Handling in PHP'>Session Handling in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/page-refresh-in-php/' rel='bookmark' title='Permanent Link: Page refresh in PHP'>Page refresh in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/how-to-get-working-site-path-and-directory-name-in-php/' rel='bookmark' title='Permanent Link: How to get working site path and directory name in php?'>How to get working site path and directory name in php?</a></li>
<li><a href='http://blog.chapagain.com.np/regular-expression-check-validation-in-php/' rel='bookmark' title='Permanent Link: Regular Expression check, Validation in PHP'>Regular Expression check, Validation in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/file-upload-in-php-simplified/' rel='bookmark' title='Permanent Link: File Upload in PHP :: Simplified'>File Upload in PHP :: Simplified</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong>Problem:</strong></p>
<p>Concatenate and fetch data from two fields of database and then break it again.</p>
<p><strong>Solution:</strong></p>
<p><span id="more-36"></span></p>
<p>Posted below.</p>
<p>The description is included in the code.</p>
<p>You have to make a mysql database. The database part is as under:</p>
<pre class="brush: sql; title: ; notranslate">
create database test;

use test;

create table user(id int(9) not null auto_increment, first_name varchar(20), last_name varchar(20), primary key(id));

insert into user(first_name, last_name) values (&quot;mukesh&quot;,&quot;chapagain&quot;);
</pre>
<p>PHP code below:</p>
<p>I have not used any loop (for, while, foreach, etc.)  here to make the code simple. :-)</p>
<pre class="brush: php; title: ; notranslate">
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Fun with strings&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;?php

// in my configuration, i am running mysql in localhost, my database username is 'root' and i don't have any database password
// i have a table called 'user' in the database 'test'

// connecting to the database server
mysql_connect(&quot;localhost&quot;,&quot;root&quot;,&quot;&quot;);

// connecting to the database
mysql_select_db(&quot;test&quot;);

// selecting data from table named 'user' where id = 1
$result = mysql_query(&quot;select concat(first_name,',',last_name) as name from user where id = '1'&quot;);

// fetching the result and assigning it to certain variables
while ($row = mysql_fetch_assoc($result))
{
$name = $row['name'];
echo &quot;$name &lt;br/&gt;&quot;; // you will get the result as first_name,last_name
}
$newName = explode(&quot;,&quot;,$name); // this will make an array with each name as values

//print_r($newName);

// print the first name as
echo &quot;First Name: &quot; . $newName[0] . &quot;&lt;br/&gt;&quot;;

// print the second name as
echo &quot;Second Name: &quot; . $newName[1] . &quot;&lt;br/&gt;&quot;;

// you can find about how many elements/items are there with the commas
$count = count($newName);
echo &quot;Count: $count &lt;br/&gt;&quot;;

// there is a function called 'implode' which will join array elements with a string
$newNameTwo = implode(&quot; &quot;,$newName); // this will print the names with spaces in between... before the names were separated with comma
echo &quot;$newNameTwo &lt;br/&gt;&quot;;

?&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Happy PHPing!</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=36&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/session-handling-in-php/' rel='bookmark' title='Permanent Link: Session Handling in PHP'>Session Handling in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/page-refresh-in-php/' rel='bookmark' title='Permanent Link: Page refresh in PHP'>Page refresh in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/how-to-get-working-site-path-and-directory-name-in-php/' rel='bookmark' title='Permanent Link: How to get working site path and directory name in php?'>How to get working site path and directory name in php?</a></li>
<li><a href='http://blog.chapagain.com.np/regular-expression-check-validation-in-php/' rel='bookmark' title='Permanent Link: Regular Expression check, Validation in PHP'>Regular Expression check, Validation in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/file-upload-in-php-simplified/' rel='bookmark' title='Permanent Link: File Upload in PHP :: Simplified'>File Upload in PHP :: Simplified</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/fun-with-strings-in-php-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add, edit, delete, login, register in PHP :: A simple and complete tutorial</title>
		<link>http://blog.chapagain.com.np/add-edit-delete-login-register-in-php-a-simple-and-complete-tutorial/</link>
		<comments>http://blog.chapagain.com.np/add-edit-delete-login-register-in-php-a-simple-and-complete-tutorial/#comments</comments>
		<pubDate>Sat, 08 Dec 2007 06:44:19 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[register]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/2007/12/08/add-edit-delete-login-register-in-php-a-simple-and-complete-tutorial/</guid>
		<description><![CDATA[Hello everyone! here is a simple and complete tutorial to add, edit, delete, login, and register in PHP with MySQL database. The description is present in the code.. in comments :D I hope those comments are sufficient to describe the code. The database part is in the sql file named &#8216;database.sql&#8217;. I have attached the [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/very-simple-add-edit-delete-display-in-php/' rel='bookmark' title='Permanent Link: Very simple add, edit, delete, display in PHP'>Very simple add, edit, delete, display in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/php-how-to-get-stock-quote-data-from-yahoo-finance-complete-code-and-tutorial/' rel='bookmark' title='Permanent Link: PHP: How to get stock quote data from Yahoo! Finance? (Complete Code and Tutorial)'>PHP: How to get stock quote data from Yahoo! Finance? (Complete Code and Tutorial)</a></li>
<li><a href='http://blog.chapagain.com.np/session-handling-in-php/' rel='bookmark' title='Permanent Link: Session Handling in PHP'>Session Handling in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/creating-dynamic-table-in-php/' rel='bookmark' title='Permanent Link: Creating dynamic table in PHP : Easy and Simple tutorial'>Creating dynamic table in PHP : Easy and Simple tutorial</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-delete-system-attribute/' rel='bookmark' title='Permanent Link: Magento: How to delete System Attribute?'>Magento: How to delete System Attribute?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hello everyone! here is a simple and complete tutorial to add, edit, delete, login, and register in PHP with MySQL database.</p>
<p>The description is present in the code.. in comments :D I hope those comments are sufficient to describe the code. The database part is in the sql file named &#8216;database.sql&#8217;.</p>
<p><span id="more-31"></span></p>
<p>I have attached the code with this post. Download it and enjoy PHPing&#8230;</p>
<p><strong>Download full source code: <a href="http://chapagain.googlecode.com/files/crud-complete.zip" rel="nofollow"  title="PHP code for add,edit,delete,login, and register">PHP code for add,edit,delete,login, and register</a></strong></p>
<p>Cheers,</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=31&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/very-simple-add-edit-delete-display-in-php/' rel='bookmark' title='Permanent Link: Very simple add, edit, delete, display in PHP'>Very simple add, edit, delete, display in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/php-how-to-get-stock-quote-data-from-yahoo-finance-complete-code-and-tutorial/' rel='bookmark' title='Permanent Link: PHP: How to get stock quote data from Yahoo! Finance? (Complete Code and Tutorial)'>PHP: How to get stock quote data from Yahoo! Finance? (Complete Code and Tutorial)</a></li>
<li><a href='http://blog.chapagain.com.np/session-handling-in-php/' rel='bookmark' title='Permanent Link: Session Handling in PHP'>Session Handling in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/creating-dynamic-table-in-php/' rel='bookmark' title='Permanent Link: Creating dynamic table in PHP : Easy and Simple tutorial'>Creating dynamic table in PHP : Easy and Simple tutorial</a></li>
<li><a href='http://blog.chapagain.com.np/magento-how-to-delete-system-attribute/' rel='bookmark' title='Permanent Link: Magento: How to delete System Attribute?'>Magento: How to delete System Attribute?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/add-edit-delete-login-register-in-php-a-simple-and-complete-tutorial/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Backup and Recovery of MySQL database</title>
		<link>http://blog.chapagain.com.np/backup-and-recovery-of-mysql-database/</link>
		<comments>http://blog.chapagain.com.np/backup-and-recovery-of-mysql-database/#comments</comments>
		<pubDate>Wed, 10 Oct 2007 12:08:18 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[dump]]></category>
		<category><![CDATA[recovery]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/2007/10/10/backup-and-recovery-of-mysql-database/</guid>
		<description><![CDATA[1) To make a backup of a single MySQL database You have to make backup before you enter inside your MySQL system i.e. by typing mysql –u username –p password . (Here, username and password indicates your MySQL server username and password.) Hence, go to your MySQL root path. Type “mysqldump –u username –p password [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/joomlapack-simply-the-best-backup-component-for-joomla/' rel='bookmark' title='Permanent Link: JoomlaPack &#8211; Simply the best backup component for Joomla!'>JoomlaPack &#8211; Simply the best backup component for Joomla!</a></li>
<li><a href='http://blog.chapagain.com.np/google-chrome-backup-profile-bookmarks-history-extensionsbest-and-easy-way/' rel='bookmark' title='Permanent Link: Backup Google Chrome Profile Bookmarks History Extensions: Best and Easy way'>Backup Google Chrome Profile Bookmarks History Extensions: Best and Easy way</a></li>
<li><a href='http://blog.chapagain.com.np/mysql-installation-problem/' rel='bookmark' title='Permanent Link: MySQL Installation Problem'>MySQL Installation Problem</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/using-database-in-pear-and-smarty/' rel='bookmark' title='Permanent Link: Using database in PEAR and Smarty'>Using database in PEAR and Smarty</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="text-align: justify">1) To make a backup of a single MySQL database<o:p> </o:p></p>
<p class="MsoNormal" style="text-align: justify">You have to make backup before you enter inside your MySQL system i.e. by typing <em>mysql –u username –p password</em> . (Here, username and password indicates your MySQL server username and password.)<o:p> </o:p></p>
<p><span id="more-23"></span></p>
<p class="MsoNormal" style="text-align: justify">Hence, go to your MySQL root path.<o:p> </o:p></p>
<p class="MsoNormal" style="text-align: justify">Type “mysqldump –u username –p password database_name > backup.sql” (without quote)<o:p> </o:p></p>
<p class="MsoNormal" style="text-align: justify">Here, <em>database_name</em> is the name of the database of which you want to create backup and <em>backup.sql</em> is the backup file name. You can name it as yourname.sql or whatever you like.<o:p> </o:p></p>
<p class="MsoNormal" style="text-align: justify">The file <em>backup.sql</em> created from the above procedure will be saved inside the ‘bin’ directory (root directory) of the MySQL server.<o:p> </o:p></p>
<p class="MsoNormal" style="text-align: justify">You can specify other location as well for the file <em>backup.sql</em> .</p>
<p class="MsoNormal" style="text-align: justify">Type “mysqldump –u username –p password database_name > E:/backup.sql” (without quote)<o:p> </o:p></p>
<p class="MsoNormal" style="text-align: justify">This will save the file to the drive E [for windows OS]<o:p> </o:p></p>
<p class="MsoNormal" style="text-align: justify">Hope, unix, linux users know it well to specify location path. <span style="font-family: Wingdings"><span></span></span><o:p><br />
</o:p></p>
<p class="MsoNormal" style="text-align: justify">Incase, your MySQL server password is blank, you need not have to type <em>–p password</em>.</p>
<p class="MsoNormal" style="text-align: justify">You can type</p>
<p class="MsoNormal" style="text-align: justify">mysqldump –u username database_name > backup.sql<o:p> </o:p></p>
<p class="MsoNormal" style="text-align: justify">Or, if your MySQL username and password both are blank than you can type</p>
<p class="MsoNormal" style="text-align: justify">mysqldump database_name > backup.sql<o:p> </o:p></p>
<p class="MsoNormal" style="text-align: justify">&nbsp;</p>
<p class="MsoNormal" style="text-align: justify">2) To make a backup of multiple MySQL database<span>  </span></p>
<p class="MsoNormal" style="text-align: justify">Type</p>
<p class="MsoNormal" style="text-align: justify">mysqldump –u username –p password &#8211;databases db1 db2 db3 > threedb.sql<o:p> </o:p></p>
<p class="MsoNormal" style="text-align: justify">Here, db1, db2, db3 are three different database name. You can use more databases, similarly.<o:p> </o:p></p>
<p class="MsoNormal" style="text-align: justify">&nbsp;</p>
<p class="MsoNormal" style="text-align: justify">3) To make a backup of all MySQL databases<o:p> </o:p></p>
<p class="MsoNormal" style="text-align: justify">Type</p>
<p class="MsoNormal" style="text-align: justify">mysqldump –u username –p password &#8211;all-databases > alldb.sql<o:p> </o:p></p>
<p class="MsoNormal" style="text-align: justify">&nbsp;</p>
<p class="MsoNormal" style="text-align: justify">4) To read back the backup we have made i.e. to create tables and databases from the backup file<o:p> </o:p></p>
<p class="MsoNormal" style="text-align: justify">If you had made a backup file of a single database, then you should create a database in your MySQL server. Then type “mysql –u username –p password db_name < backup.sql”<o:p> </o:p></p>
<p class="MsoNormal" style="text-align: justify">Here, <em>db_name</em> is the database name in your MySQL server. All tables are created inside this database from the <em>backup.sql</em> file.<o:p> </o:p></p>
<p class="MsoNormal" style="text-align: justify">If you had made a backup file of multiple databases, then you don’t have to create database beforehand. The backup file consists of the query to create all the databases and tables. Note it here, that you don’t have to specify the database name. You just have to type “mysql –u username –p password < backup.sql” and that’s all.<o:p> </o:p></p>
<p class="MsoNormal" style="text-align: justify">Note: Be careful to specify the proper location of your backup.sql file.<o:p> </o:p></p>
<p class="MsoNormal" style="text-align: justify">Enjoy!!!</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=23&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/joomlapack-simply-the-best-backup-component-for-joomla/' rel='bookmark' title='Permanent Link: JoomlaPack &#8211; Simply the best backup component for Joomla!'>JoomlaPack &#8211; Simply the best backup component for Joomla!</a></li>
<li><a href='http://blog.chapagain.com.np/google-chrome-backup-profile-bookmarks-history-extensionsbest-and-easy-way/' rel='bookmark' title='Permanent Link: Backup Google Chrome Profile Bookmarks History Extensions: Best and Easy way'>Backup Google Chrome Profile Bookmarks History Extensions: Best and Easy way</a></li>
<li><a href='http://blog.chapagain.com.np/mysql-installation-problem/' rel='bookmark' title='Permanent Link: MySQL Installation Problem'>MySQL Installation Problem</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/using-database-in-pear-and-smarty/' rel='bookmark' title='Permanent Link: Using database in PEAR and Smarty'>Using database in PEAR and Smarty</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/backup-and-recovery-of-mysql-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Server doesn’t start</title>
		<link>http://blog.chapagain.com.np/mysql-server-doesnt-start-2/</link>
		<comments>http://blog.chapagain.com.np/mysql-server-doesnt-start-2/#comments</comments>
		<pubDate>Wed, 05 Sep 2007 23:24:41 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[start]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=17</guid>
		<description><![CDATA[Problem: “Fails to start the service. Please wait 30 seconds to try again.” I faced this problem 2 years back when I was a newbie to MySQL. I was just starting to learn PHP and MySQL at that time. [PS: The problem was faced and tackled in Windows platform.] Solution: Well, there is my.ini file [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/mysql-installation-problem/' rel='bookmark' title='Permanent Link: MySQL Installation Problem'>MySQL Installation Problem</a></li>
<li><a href='http://blog.chapagain.com.np/backup-and-recovery-of-mysql-database/' rel='bookmark' title='Permanent Link: Backup and Recovery of MySQL database'>Backup and Recovery of MySQL database</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/magento-upgrading-mysql-setup-of-a-module/' rel='bookmark' title='Permanent Link: Magento: Upgrading mysql setup of a module'>Magento: Upgrading mysql setup of a module</a></li>
<li><a href='http://blog.chapagain.com.np/wamp-xampp-localhost-server-not-working/' rel='bookmark' title='Permanent Link: WAMP XAMPP: Localhost server not working'>WAMP XAMPP: Localhost server not working</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong>Problem:</strong></p>
<p class="MsoNormal" style="text-align:justify;"><span class="msgbodytext">“<em>Fails to start the service. Please wait 30 seconds to try again.</em>” </span></p>
<p class="MsoNormal" style="text-align:justify;"><span class="msgbodytext">I faced this problem 2 years back when I was a newbie to MySQL. I was just starting to learn PHP and MySQL at that time. </span></p>
<p><span id="more-54"></span></p>
<p class="MsoNormal" style="text-align:justify;">[PS:<strong> </strong>The problem was faced and tackled in Windows platform.]<span class="msgbodytext"> </span></p>
<p class="MsoNormal" style="text-align:justify;"><span class="msgbodytext"><strong>Solution:</strong><br />
</span></p>
<p class="MsoNormal" style="text-align:justify;"><span class="msgbodytext">Well, there is my.ini file to control the server. It might be in your </span></p>
<p>C:/Documents and Settings/Administrator/WINDOWS/my.ini</p>
<p class="MsoNormal" style="text-align:justify;">[I suppose that your Operating System is installed in C: drive]</p>
<p class="MsoNormal" style="text-align:justify;">Here, “Administrator” is the user with the administrator privilege. This could be different as you might have the admin user with your name.</p>
<p class="MsoNormal" style="text-align:justify;">Copy the my.ini file from the above location to</p>
<p>C:/WINDOWS/my.ini</p>
<p class="MsoNormal" style="text-align:justify;">And you are done! Your mysql server will start quite happily.</p>
<p class="MsoNormal" style="text-align:justify;">Cheers,</p>
<p class="MsoNormal" style="text-align:justify;">Mukesh</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=54&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/mysql-installation-problem/' rel='bookmark' title='Permanent Link: MySQL Installation Problem'>MySQL Installation Problem</a></li>
<li><a href='http://blog.chapagain.com.np/backup-and-recovery-of-mysql-database/' rel='bookmark' title='Permanent Link: Backup and Recovery of MySQL database'>Backup and Recovery of MySQL database</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/magento-upgrading-mysql-setup-of-a-module/' rel='bookmark' title='Permanent Link: Magento: Upgrading mysql setup of a module'>Magento: Upgrading mysql setup of a module</a></li>
<li><a href='http://blog.chapagain.com.np/wamp-xampp-localhost-server-not-working/' rel='bookmark' title='Permanent Link: WAMP XAMPP: Localhost server not working'>WAMP XAMPP: Localhost server not working</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/mysql-server-doesnt-start-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Installation Problem</title>
		<link>http://blog.chapagain.com.np/mysql-installation-problem/</link>
		<comments>http://blog.chapagain.com.np/mysql-installation-problem/#comments</comments>
		<pubDate>Mon, 20 Aug 2007 03:45:22 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=14</guid>
		<description><![CDATA[Problem: can&#8217;t create pid file: no such file or directory I had this problem and had a very tough and frustrating time with it. While I was installing a fresh copy of MySQL 5 in Windows XP, I got this problem. (I was installing it from the installer i.e. setup file.) The server was not [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/backup-and-recovery-of-mysql-database/' rel='bookmark' title='Permanent Link: Backup and Recovery of MySQL database'>Backup and Recovery of MySQL database</a></li>
<li><a href='http://blog.chapagain.com.np/mysql-server-doesnt-start-2/' rel='bookmark' title='Permanent Link: MySQL Server doesn’t start'>MySQL Server doesn’t start</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/magento-upgrading-mysql-setup-of-a-module/' rel='bookmark' title='Permanent Link: Magento: Upgrading mysql setup of a module'>Magento: Upgrading mysql setup of a module</a></li>
<li><a href='http://blog.chapagain.com.np/configuration-error-on-new-magento-installation/' rel='bookmark' title='Permanent Link: Configuration error on new Magento installation'>Configuration error on new Magento installation</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Problem: <em>can&#8217;t create pid file: no such file or directory</em></p>
<p>I had this problem and had a very tough and frustrating time with it. While I was installing a fresh copy of MySQL 5 in Windows XP, I got this problem. (I was installing it from the installer i.e. setup file.) The server was not starting and &#8216;error 0&#8242; was displayed. I tried to start the server from the command line by typing &#8220;mysqld-nt &#8211;console&#8221; and then got the error &#8220;can&#8217;t create pid file: no such file or directory&#8221;. It was also displaying the message like &#8220;cannot create/write file C:\Program Files\MySQL\MySQL Server 5.0\data\com2.pid&#8221;.</p>
<p>Solution:</p>
<p><span id="more-14"></span></p>
<p>The main problem was my computer name. My computer name was &#8216;com2&#8242;. MySQL makes the file with the computer name in the directory of it&#8217;s data (in my case C:\Program Files\MySQL\MySQL Server 5.0\data\) . Now, it was unable to create a file named com2 (which was my computer name) because in WINDOWS you cannot make file/folder with the name com1,com2,com3&#8230; and so on.</p>
<p>Hence, I changed my computer name, restarted my computer and then reconfigured MySQL. All well done and MySQL started running.</p>
<p>Cheers,</p>
<p>Mukesh</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=14&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/backup-and-recovery-of-mysql-database/' rel='bookmark' title='Permanent Link: Backup and Recovery of MySQL database'>Backup and Recovery of MySQL database</a></li>
<li><a href='http://blog.chapagain.com.np/mysql-server-doesnt-start-2/' rel='bookmark' title='Permanent Link: MySQL Server doesn’t start'>MySQL Server doesn’t start</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/magento-upgrading-mysql-setup-of-a-module/' rel='bookmark' title='Permanent Link: Magento: Upgrading mysql setup of a module'>Magento: Upgrading mysql setup of a module</a></li>
<li><a href='http://blog.chapagain.com.np/configuration-error-on-new-magento-installation/' rel='bookmark' title='Permanent Link: Configuration error on new Magento installation'>Configuration error on new Magento installation</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/mysql-installation-problem/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! -->
