<?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>Database Lessons &#187; database</title>
	<atom:link href="http://databaselessons.com/blog/tag/database/feed/" rel="self" type="application/rss+xml" />
	<link>http://databaselessons.com/blog</link>
	<description>Tips for MS Access users</description>
	<lastBuildDate>Tue, 19 Jul 2011 11:48:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Cascading Queries in a Single Query</title>
		<link>http://databaselessons.com/blog/cascading-queries-in-a-single-query/</link>
		<comments>http://databaselessons.com/blog/cascading-queries-in-a-single-query/#comments</comments>
		<pubDate>Sat, 29 May 2010 10:05:16 +0000</pubDate>
		<dc:creator>manxman</dc:creator>
				<category><![CDATA[Queries]]></category>
		<category><![CDATA[access]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[sub-select query]]></category>

		<guid isPermaLink="false">http://databaselessons.com/blog/?p=130</guid>
		<description><![CDATA[As promised, here is the query within a query solution that simplifies the last article&#8217;s idea. We saw in my last post how a question like &#8220;Who was the first person to borrow a book?&#8221; could be solved by having a query use the results from another query. That required 2 actual queries saved separately. [...]]]></description>
			<content:encoded><![CDATA[<p>As promised, here is the query within a query solution that simplifies the last article&#8217;s idea.</p>
<p>We saw in my last post how a question like &#8220;Who was the first person to borrow a book?&#8221; could be solved by having a query use the results from another query. That required 2 actual queries saved separately. Now let&#8217;s see that same concept done in a single saved query.</p>
<p>Let&#8217;s break the problem down into steps.</p>
<p>Step 1 &#8211; determine the earliest case of a book being borrowed</p>
<pre>
SELECT Min(tblBorrowing.dtmDateDue) AS EarliestDate
FROM tblBorrowing
WHERE (((tblBorrowing.lngBookID)=1));
</pre>
<p>I have shown the raw SQL above (good idea to learn that stuff!), but you could have just used the query builder to create a query like this following.</p>
<p><img src="http://databaselessons.com/blog/wp-content/uploads/minbook4.jpg" alt="sub-select query part 1" title="sub-select query part 1" width="326" height="257" class="aligncenter size-full wp-image-134" /></p>
<p>Note my use of a custom field name in &#8220;EarliestDate&#8221;.</p>
<p>Step 2 &#8211; Utilize the first query in a where clause</p>
<p><img src="http://databaselessons.com/blog/wp-content/uploads/minbook5.jpg" alt="final sub-query design" title="final sub-query design" width="498" height="242" class="aligncenter size-full wp-image-136" /></p>
<p>Note how I went back and created the original query style, utilizing all the tables and desired fields, and then added the first query as a criteria for the date field.</p>
<p>This creates a single saved query, rather than 2 separate ones. Here is the resulting (and somewhat hard to read!) SQL code. </p>
<pre>
SELECT tblCustomers.strCustomerName, tblBooks.strBookName,
tblBorrowing.dtmDateDue
FROM (tblBooks INNER JOIN tblBorrowing ON tblBooks.lngBookID =
tblBorrowing.lngBookID) INNER JOIN tblCustomers ON
tblBorrowing.lngCustomerID = tblCustomers.lngCustomerID
WHERE (((tblBooks.lngBookID)=1) AND tblBorrowing.dtmDateDue =
(SELECT Min(tblBorrowing.dtmDateDue) AS EarliestDate
FROM tblBorrowing
WHERE (((tblBorrowing.lngBookID)=1));
));
</pre>
<p>I will admit, however, that I often clutter my databases with the 2 (or more!!!) query solutions as discussed last week. I find them easier to comprehend and fine tune.</p>
<p>If you want a cleaner looking Queries tab, use this sub-select version!</p>
]]></content:encoded>
			<wfw:commentRss>http://databaselessons.com/blog/cascading-queries-in-a-single-query/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Query On Query</title>
		<link>http://databaselessons.com/blog/query-on-query/</link>
		<comments>http://databaselessons.com/blog/query-on-query/#comments</comments>
		<pubDate>Sat, 22 May 2010 09:58:50 +0000</pubDate>
		<dc:creator>manxman</dc:creator>
				<category><![CDATA[Queries]]></category>
		<category><![CDATA[access]]></category>
		<category><![CDATA[cascading queries]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[query]]></category>

		<guid isPermaLink="false">http://databaselessons.com/blog/?p=120</guid>
		<description><![CDATA[Some of my Access Database using readers may not know that a query can use another query for its source. Many of us get into the mindset that a query only reads from a table. So, if I create a new query and choose Design View, the next screen that pops up is called the [...]]]></description>
			<content:encoded><![CDATA[<p>Some of my Access Database using readers may not know that a query can use another query for its source. Many of us get into the mindset that a query only reads from a table.</p>
<p>So, if I create a new query and choose Design View, the next screen that pops up is called the Show Table dialogue box. But look closer. It is not only showing Tables. There are also tabs for Queries and Both.</p>
<p><img src="http://databaselessons.com/blog/wp-content/uploads/newquery.jpg" alt="Add Table Dialogue Box" title="Add Table Dialogue Box" width="372" height="294" class="aligncenter size-full wp-image-121" /></p>
<p>When is this useful?</p>
<p>One of the best examples is a library book borrowing database. Answer questions like this. Who was the first person to borrow the book, &#8220;How to Create a Query&#8221;?</p>
<p>Here are the tables of a simple version of this concept.</p>
<pre>
tblBooks
---------
lngBookID
strBookName

tblCustomers
-------------
lngCustomerID
strCustomerName

tblBorrowing
------------
lngBorrowID
lngBookID
lngCustomerID
dtmDateDue
</pre>
<p>The first thought may be to create a &#8220;Totals&#8221; query that asks for the Min function of the date field. Like this.</p>
<p><img src="http://databaselessons.com/blog/wp-content/uploads/minbook1.jpg" alt="basic query for book lending" title="basic query for book lending" width="485" height="268" class="aligncenter size-full wp-image-123" /></p>
<p>This does not work directly, as it returns the first time that each customer borrowed that book. We just want the very first customer who borrowed the book. We can visually see that it was David Martin, but we want the query to determine this by itself.</p>
<p><img src="http://databaselessons.com/blog/wp-content/uploads/minbook2.jpg" alt="initial who borrowed first query" title="initial who borrowed first query" width="577" height="79" class="aligncenter size-full wp-image-125" /></p>
<p>One solution to this problem follows.</p>
<p>Remove the Customer Name from the first query. Since it is not needed anymore, remove the Customer table as well. The query now returns just one record; that of the first time the book was borrowed. Save that query as qryMinQueryBook, or similar.</p>
<p>Now, start a new query. Add in the query you just created, as well as the Customer table and the Borrowing table. Link the 2 date fields.</p>
<p><img src="http://databaselessons.com/blog/wp-content/uploads/minbook3.jpg" alt="final solution query" title="final solution query" width="430" height="257" class="aligncenter size-full wp-image-127" /></p>
<p>This will produce a single record; that of David Martin.</p>
<p>One term that is used for this method is &#8220;Cascading Queries&#8221;. I have personally used this technique to multiple layers, and horizontally had more than 1 query as well.</p>
<p>In my next article I will show how simple cascading queries like the one above can been done in a single query.</p>
]]></content:encoded>
			<wfw:commentRss>http://databaselessons.com/blog/query-on-query/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introduction to Queries</title>
		<link>http://databaselessons.com/blog/introduction-to-queries/</link>
		<comments>http://databaselessons.com/blog/introduction-to-queries/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 11:51:45 +0000</pubDate>
		<dc:creator>manxman</dc:creator>
				<category><![CDATA[Queries]]></category>
		<category><![CDATA[append query]]></category>
		<category><![CDATA[criteria]]></category>
		<category><![CDATA[crosstab query]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[delete query]]></category>
		<category><![CDATA[make table query]]></category>
		<category><![CDATA[ms access]]></category>
		<category><![CDATA[parameters]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[select query]]></category>
		<category><![CDATA[tables]]></category>
		<category><![CDATA[update query]]></category>

		<guid isPermaLink="false">http://databaselessons.com/blog/?p=45</guid>
		<description><![CDATA[In MS Access, what is a query? This series of articles on MS Access Queries will start off from raw basics. Most of my regulars will already know this material, and so please allow for the fact that this is meant for &#8220;newbies&#8221; to some degree. I promise to get into more challenging topics as [...]]]></description>
			<content:encoded><![CDATA[<p>In MS Access, what is a query?</p>
<blockquote><p>This series of articles on MS Access Queries will start off from raw basics. Most of my regulars will already know this material, and so please allow for the fact that this is meant for &#8220;newbies&#8221; to some degree. I promise to get into more challenging topics as we go along.
</p></blockquote>
<p>Simply put, a query is a question asked of the database, specifically of one or more of the tables in the database. A query&#8217;s answer returns values from selected fields (columns) and records (rows).</p>
<p>A basic example could be, &#8220;Which of our customers are located in Springfield?&#8221;</p>
<p>A more complex query (or question) could be, &#8220;Which of our customers in Springfield have not ordered any products in the past 6 months?&#8221;</p>
<p>The above examples are of just one type of query; the select query. MS Access has a number of types of queries available.</p>
<blockquote><p>This series of articles will be written based on Access 2000. Newer versions of Access may have added to this list. The principles explained here should work fine on version 2000 and any newer ones.</p></blockquote>
<p><strong>Types of Queries</strong></p>
<p>If you create a query manually (more on this later) you choose from a list of 6 query types.</p>
<ul>
<li>Select Query retrieves data from one or more tables (or queries!) </li>
<li>Crosstab query displays summarized data in a column/row format (like pivot tables in Excel)</li>
<li>Make Table query creates a new table based on data from one or more existing tables (or queries!)</li>
<li>Update query updates the data in a table (a simple example would be &#8220;Add an across the board raise of 2% to each employee&#8217;s pay rate&#8221;)</li>
<li>Append query adds new records (rows) to a table</li>
<li>Delete query will delete records (rows) from a table</ul>
</li>
<p>Most of the above queries accept criteria (parameters) such that only some of the records in a table are retrieved or updated.</p>
<p>NEXT: How to create a basic query.</p>
]]></content:encoded>
			<wfw:commentRss>http://databaselessons.com/blog/introduction-to-queries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Access, FTP, PHP, MySQL &#8211; Part 3</title>
		<link>http://databaselessons.com/blog/access-ftp-php-mysql-part-3/</link>
		<comments>http://databaselessons.com/blog/access-ftp-php-mysql-part-3/#comments</comments>
		<pubDate>Tue, 11 Nov 2008 18:01:22 +0000</pubDate>
		<dc:creator>manxman</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[ms access]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://databaselessons.com/blog/?p=37</guid>
		<description><![CDATA[Continuing with my series about using Access on a PC to feed a MySQL database on the web! Read part 3 here. This part describes the structure of the 2 databases involved. One is an MS Access database on a local PC. The other is a MySQL database on a webserver. Remember that this method [...]]]></description>
			<content:encoded><![CDATA[<p>Continuing with my series about using Access on a PC to feed a MySQL database on the web! Read <a href="http://www.databaselessons.com/access-ftp-php-mysql-3.php">part 3 here</a>. This part describes the structure of the 2 databases involved. One is an MS Access database on a local PC. The other is a MySQL database on a webserver.</p>
<p>Remember that this method was created for websites that exist on servers that do NOT allow remote MySQL connections. Some servers do allow the remote connections, which simplifies the whole process.</p>
]]></content:encoded>
			<wfw:commentRss>http://databaselessons.com/blog/access-ftp-php-mysql-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Relational Database Design Guidelines</title>
		<link>http://databaselessons.com/blog/relational-database-design-guidelines/</link>
		<comments>http://databaselessons.com/blog/relational-database-design-guidelines/#comments</comments>
		<pubDate>Thu, 28 Aug 2008 01:45:39 +0000</pubDate>
		<dc:creator>manxman</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[ms access]]></category>
		<category><![CDATA[relational design]]></category>

		<guid isPermaLink="false">http://databaselessons.com/blog/?p=26</guid>
		<description><![CDATA[While designing a relational database, it is a good idea to distribute the information in multiple tables. It is not advisable to store all the information in a single table, although it is easier to design. When your database grows in size, the efficiency decreases accordingly. To read the rest of this article, Relational Database [...]]]></description>
			<content:encoded><![CDATA[<p>While designing a relational database, it is a good idea to distribute the information in multiple tables. It is not advisable to store all the information in a single table, although it is easier to design. When your database grows in size, the efficiency decreases accordingly.</p>
<p>To read the rest of this article, <a href="http://www.databaselessons.com/relational-database-design-guidelines.php">Relational Database Design Guidelines</a> &#8211; an introduction.</p>
]]></content:encoded>
			<wfw:commentRss>http://databaselessons.com/blog/relational-database-design-guidelines/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
