The power of a relational database such as Oracle, SQL Server, MySQL and Access is the ability to relate two or more tables based on common fields. Here is how you can join two tables on a common field. I am using MS Access's Northwind database to write the SQL statement.
1. Database Database Open your relational database. For my example I am using Microsoft's Northwind database, which is the database that comes with Microsoft.
2. Tables Tables I am going to use the orders table and the orders detail table and I will relate the two tables based on the Order ID field. Each order has a unique index called the order id. This order id is saved in the order details table since you can have multiple items purchased on the same order.
3. SQL statement SQL statement I selected a couple of fields from both tables so you can see how the data is returned. I then join the two tables on the order if field. So my SQL statement looks like this: "SELECT [Order Details].OrderID, [Order Details].ProductID, Orders.OrderDate, Orders.ShippedDate, [Order Details].UnitPrice FROM Orders, [order details] where Orders.OrderID = [Order Details].OrderID;" Anything you see enclosed with [] means that the field or table name is more than one word using a space to separate the words.
4. Final results Final results Now run your sql statement. You will see the fields selected displayed and the two tables joined.
American Angler Sport Fishing Take the time to learn with a professional to help you to make the most out of every tournament you enter. Winning the prize can help to lower these costs and make it all well worth it!