<?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>veppa laboratory &#187; MySql</title>
	<atom:link href="http://www.veppa.com/blog/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.veppa.com/blog</link>
	<description>discover how it is done.</description>
	<lastBuildDate>Fri, 18 Dec 2009 14:50:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Free Wallpaper Script ready for download</title>
		<link>http://www.veppa.com/blog/2009/12/18/free-wallpaper-script-ready-for-download/</link>
		<comments>http://www.veppa.com/blog/2009/12/18/free-wallpaper-script-ready-for-download/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 14:50:34 +0000</pubDate>
		<dc:creator>veppa</dc:creator>
				<category><![CDATA[MySql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Website]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[Free Wallpaper Script]]></category>

		<guid isPermaLink="false">http://www.veppa.com/blog/?p=52</guid>
		<description><![CDATA[Free wallpaper script is a free PHP script to create wallpaper sites. I have a wallpaper site for couple years now and each year I am rewriting it in order to improve it. I am so happy with it so I decided to share script for creating wallpaper sites. It is simple site to upload [...]


Related posts:<ol><li><a href='http://www.veppa.com/blog/2005/05/17/published-desktop-wallpapers-site/' rel='bookmark' title='Permanent Link: Published desktop wallpapers site'>Published desktop wallpapers site</a> <small>Published desktop wallpaper download site containing huge collection of movies,...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Free wallpaper script is a free PHP script to create wallpaper sites. I have a <a href="http://www.genctel.com">wallpaper site</a> for couple years now and each year I am rewriting it in order to improve it. I am so happy with it so I decided to share script for creating wallpaper sites.<span id="more-52"></span><br />
It is simple site to upload and share desctop wallpapers. Each wallpaper can be commented by site visitors. Also to promote best wallpapers there is rating system for wallpapers. Site visitors can rate up by adding one vote to it if they like that wallpaper. In same way they can vote down it to reduce rating score for it. This way site visitors can order wallpapers by rating to find best wallpapers on the site.</p>
<div class="wp-caption alignnone" style="width: 510px"><a href="http://www.veppa.com/free-wallpaper-script/"><img title="Free Wallpaper Script" src="http://www.veppa.com/public/doc/img/free-wallpaper-script.jpg" alt="Free Wallpaper Script home page" width="500" height="340" /></a><p class="wp-caption-text">Free Wallpaper Script home page</p></div>
<p>Other functionality, system requirements, screenshots, download link and demo site can be found on <a href="http://www.veppa.com/free-wallpaper-script/">Free wallpaper script</a> page.<br />
<a href="http://www.veppa.com/web/wallpaper-script/demo/">Demo site for testing wallpaper script</a>.</p>



Share and Enjoy:


	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.veppa.com%2Fblog%2F2009%2F12%2F18%2Ffree-wallpaper-script-ready-for-download%2F&amp;title=Free%20Wallpaper%20Script%20ready%20for%20download&amp;bodytext=Free%20wallpaper%20script%20is%20a%20free%20PHP%20script%20to%20create%20wallpaper%20sites.%20I%20have%20a%20wallpaper%20site%20for%20couple%20years%20now%20and%20each%20year%20I%20am%20rewriting%20it%20in%20order%20to%20improve%20it.%20I%20am%20so%20happy%20with%20it%20so%20I%20decided%20to%20share%20script%20for%20creating%20wallpaper%20sites" title="Digg"><img src="http://www.veppa.com/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.veppa.com%2Fblog%2F2009%2F12%2F18%2Ffree-wallpaper-script-ready-for-download%2F&amp;title=Free%20Wallpaper%20Script%20ready%20for%20download&amp;notes=Free%20wallpaper%20script%20is%20a%20free%20PHP%20script%20to%20create%20wallpaper%20sites.%20I%20have%20a%20wallpaper%20site%20for%20couple%20years%20now%20and%20each%20year%20I%20am%20rewriting%20it%20in%20order%20to%20improve%20it.%20I%20am%20so%20happy%20with%20it%20so%20I%20decided%20to%20share%20script%20for%20creating%20wallpaper%20sites" title="del.icio.us"><img src="http://www.veppa.com/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.veppa.com%2Fblog%2F2009%2F12%2F18%2Ffree-wallpaper-script-ready-for-download%2F&amp;t=Free%20Wallpaper%20Script%20ready%20for%20download" title="Facebook"><img src="http://www.veppa.com/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.veppa.com%2Fblog%2F2009%2F12%2F18%2Ffree-wallpaper-script-ready-for-download%2F&amp;title=Free%20Wallpaper%20Script%20ready%20for%20download" title="Mixx"><img src="http://www.veppa.com/blog/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.veppa.com%2Fblog%2F2009%2F12%2F18%2Ffree-wallpaper-script-ready-for-download%2F&amp;title=Free%20Wallpaper%20Script%20ready%20for%20download&amp;annotation=Free%20wallpaper%20script%20is%20a%20free%20PHP%20script%20to%20create%20wallpaper%20sites.%20I%20have%20a%20wallpaper%20site%20for%20couple%20years%20now%20and%20each%20year%20I%20am%20rewriting%20it%20in%20order%20to%20improve%20it.%20I%20am%20so%20happy%20with%20it%20so%20I%20decided%20to%20share%20script%20for%20creating%20wallpaper%20sites" title="Google Bookmarks"><img src="http://www.veppa.com/blog/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Free%20Wallpaper%20Script%20ready%20for%20download&amp;body=http%3A%2F%2Fwww.veppa.com%2Fblog%2F2009%2F12%2F18%2Ffree-wallpaper-script-ready-for-download%2F" title="email"><img src="http://www.veppa.com/blog/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email link Free Wallpaper Script ready for download" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.veppa.com%2Fblog%2F2009%2F12%2F18%2Ffree-wallpaper-script-ready-for-download%2F&amp;title=Free%20Wallpaper%20Script%20ready%20for%20download" title="StumbleUpon"><img src="http://www.veppa.com/blog/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="" title="TwitThis"><img src="http://www.veppa.com/blog/wp-content/plugins/sociable/images/" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a>


<br/><br/>

<p>Related posts:<ol><li><a href='http://www.veppa.com/blog/2005/05/17/published-desktop-wallpapers-site/' rel='bookmark' title='Permanent Link: Published desktop wallpapers site'>Published desktop wallpapers site</a> <small>Published desktop wallpaper download site containing huge collection of movies,...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.veppa.com/blog/2009/12/18/free-wallpaper-script-ready-for-download/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Problem with using AND, OR for single column values</title>
		<link>http://www.veppa.com/blog/2006/12/09/problem-with-using-and-or-for-single-column-values/</link>
		<comments>http://www.veppa.com/blog/2006/12/09/problem-with-using-and-or-for-single-column-values/#comments</comments>
		<pubDate>Sat, 09 Dec 2006 16:54:12 +0000</pubDate>
		<dc:creator>veppa</dc:creator>
				<category><![CDATA[MySql]]></category>

		<guid isPermaLink="false">http://www.veppa.com/blog/2006/12/09/problem-with-using-and-or-for-single-column-values/</guid>
		<description><![CDATA[I have a MySql database table as shown in image . Where table has thousands of records with any integer and varchar values in id1 and id2. I want to select values where id1=(1 and (2 or 3)). Which will result in id2=a,b,c. Result may be several hundred records for real table and I will [...]


Related posts:<ol><li><a href='http://www.veppa.com/blog/2006/11/24/margiana-data-visualization-experiment/' rel='bookmark' title='Permanent Link: Margiana data visualization experiment'>Margiana data visualization experiment</a> <small>Honored to announce an experimental web site Margiana (www.margiana.com). Web...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img align="left" id="image18" alt="Example Mysql table" src="http://www.veppa.com/blog/wp-content/uploads/2006/12/mysql_table.gif" title="Problem with using AND, OR for single column values" />I have a <a title="The world's most popular open source database" target="_blank" href="http://www.mysql.com/">MySql </a>database table as shown in image . Where table has thousands of records with any integer and varchar values in id1 and id2.</p>
<p>I want to select values where id1=(1 and (2 or 3)). Which will result in id2=a,b,c.</p>
<p>Result may be several hundred records for real table and I will be using LIMIT start, records for  showing results on each page.</p>
<ul>
<li>For selecting records id1= 1 and 2 and 3:<br />
<strong> SELECT *, count(*) as total_count FROM table WHERE id1=1 OR id1=2 OR id1=3 GROUP BY id2 HAVING l_count=&#8217;3&#8242;;</strong></li>
<li>For selecting records id1= 1 or 2 or 3:<br />
<strong> SELECT *, count(*) as total_count FROM table WHERE id1=1 OR id1=2 OR id1=3 GROUP BY id2;</strong></li>
</ul>
<p>But how to select mixed and , or statements, like id1=(1 and (2 or 3))?<br />
I found some solution.</p>
<p><span id="more-17"></span> To select id1=(1 AND (2 OR 3))</p>
<p><strong>SELECT t1.* FROM test t1 INNER JOIN  test t2 USING (id2) WHERE t1.id1=1 AND (t2.id1=2 OR t2.id1=3) GROUP BY t1.id2;</strong></p>
<p>Which requires using JOIN for every AND condition in the query. For example to select id1=(1 AND 2 AND 3 AND (4 OR 5 OR 6)). Query sting will be as following.</p>
<p><strong>SELECT t1.* FROM test t1 INNER JOIN  test t2 USING (id2)<br />
INNER JOIN  test t3 USING (id2)<br />
INNER JOIN  test t4 USING (id2)<br />
WHERE t1.id1=1 AND t2.id1=2 AND t3.id1=3 AND (t4.id1=4 OR t4.id1=5 OR t4.id1=6) GROUP BY t1.id2;</strong></p>
<p>Which will get bigger and bigger id there are more AND conditions required.<br />
I think that there must be more optimal way doing it. If you have any suggestion or solution you are wellcome to comment on here.</p>
<p>I came up with this problem when someone wants to list all images having tags <strong>(</strong>(&#8220;North London&#8221; or &#8220;East London&#8221; or &#8220;City&#8221;) and &#8220;street&#8221; and &#8220;birds&#8221; and &#8220;flowers&#8221; and &#8220;people&#8221;<strong>)</strong> . Where each image can have several tags and each tag may have thousands images.</p>



Share and Enjoy:


	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.veppa.com%2Fblog%2F2006%2F12%2F09%2Fproblem-with-using-and-or-for-single-column-values%2F&amp;title=Problem%20with%20using%20AND%2C%20OR%20for%20single%20column%20values&amp;bodytext=I%20have%20a%20MySql%20database%20table%20as%20shown%20in%20image%20.%20Where%20table%20has%20thousands%20of%20records%20with%20any%20integer%20and%20varchar%20values%20in%20id1%20and%20id2.%0D%0A%0D%0AI%20want%20to%20select%20values%20where%20id1%3D%281%20and%20%282%20or%203%29%29.%20Which%20will%20result%20in%20id2%3Da%2Cb%2Cc.%0D%0A%0D%0AResult%20may%20be%20several" title="Digg"><img src="http://www.veppa.com/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.veppa.com%2Fblog%2F2006%2F12%2F09%2Fproblem-with-using-and-or-for-single-column-values%2F&amp;title=Problem%20with%20using%20AND%2C%20OR%20for%20single%20column%20values&amp;notes=I%20have%20a%20MySql%20database%20table%20as%20shown%20in%20image%20.%20Where%20table%20has%20thousands%20of%20records%20with%20any%20integer%20and%20varchar%20values%20in%20id1%20and%20id2.%0D%0A%0D%0AI%20want%20to%20select%20values%20where%20id1%3D%281%20and%20%282%20or%203%29%29.%20Which%20will%20result%20in%20id2%3Da%2Cb%2Cc.%0D%0A%0D%0AResult%20may%20be%20several" title="del.icio.us"><img src="http://www.veppa.com/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.veppa.com%2Fblog%2F2006%2F12%2F09%2Fproblem-with-using-and-or-for-single-column-values%2F&amp;t=Problem%20with%20using%20AND%2C%20OR%20for%20single%20column%20values" title="Facebook"><img src="http://www.veppa.com/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.veppa.com%2Fblog%2F2006%2F12%2F09%2Fproblem-with-using-and-or-for-single-column-values%2F&amp;title=Problem%20with%20using%20AND%2C%20OR%20for%20single%20column%20values" title="Mixx"><img src="http://www.veppa.com/blog/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.veppa.com%2Fblog%2F2006%2F12%2F09%2Fproblem-with-using-and-or-for-single-column-values%2F&amp;title=Problem%20with%20using%20AND%2C%20OR%20for%20single%20column%20values&amp;annotation=I%20have%20a%20MySql%20database%20table%20as%20shown%20in%20image%20.%20Where%20table%20has%20thousands%20of%20records%20with%20any%20integer%20and%20varchar%20values%20in%20id1%20and%20id2.%0D%0A%0D%0AI%20want%20to%20select%20values%20where%20id1%3D%281%20and%20%282%20or%203%29%29.%20Which%20will%20result%20in%20id2%3Da%2Cb%2Cc.%0D%0A%0D%0AResult%20may%20be%20several" title="Google Bookmarks"><img src="http://www.veppa.com/blog/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Problem%20with%20using%20AND%2C%20OR%20for%20single%20column%20values&amp;body=http%3A%2F%2Fwww.veppa.com%2Fblog%2F2006%2F12%2F09%2Fproblem-with-using-and-or-for-single-column-values%2F" title="email"><img src="http://www.veppa.com/blog/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email link Problem with using AND, OR for single column values" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.veppa.com%2Fblog%2F2006%2F12%2F09%2Fproblem-with-using-and-or-for-single-column-values%2F&amp;title=Problem%20with%20using%20AND%2C%20OR%20for%20single%20column%20values" title="StumbleUpon"><img src="http://www.veppa.com/blog/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="" title="TwitThis"><img src="http://www.veppa.com/blog/wp-content/plugins/sociable/images/" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a>


<br/><br/>

<p>Related posts:<ol><li><a href='http://www.veppa.com/blog/2006/11/24/margiana-data-visualization-experiment/' rel='bookmark' title='Permanent Link: Margiana data visualization experiment'>Margiana data visualization experiment</a> <small>Honored to announce an experimental web site Margiana (www.margiana.com). Web...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.veppa.com/blog/2006/12/09/problem-with-using-and-or-for-single-column-values/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
