February 22nd, 2002, 04:55 AM
August 16th, 2002, 04:35 PM
thanks so much for putting such a "to the point" informative series of tutorials together. i am trying to learn sql and almost every site i've visited assumes that you know "so and so" to get past some sticking points that are simple if you know about them and frustrating if you don't. you have done a great job in finding useful items for everyday work and explained and illustrated them in a straight forward manner. thanks again. you've been a big help to me. keep them coming
December 2nd, 2002, 04:50 AM
Re: More Join Options?
Name: Matthew Nuzum
Subject: More Join Options?
Date: 01-22-2001 07:16:00 MST (GMT -7)
I'm new to using joins, and have a question that expands on this example:
SELECT fname, lname, title FROM members, videos, status WHERE
status.member_id = members.member_id AND status.video_id = videos.video_id;
The example shows all the records that have related data in each of the three tables.
Let's modify the example to say that you wanted a complete inventory listing plus any extra info such as whom it was checked out to if it's checked out.
I've played with the sytax and I've found that I have to use the words LEFT JOIN to get it to do what I want. i don't know what LEFT JOIN means, and I don't know how to use two or more in the same query.
Here's my exact query (that doesn't work):
LEFT JOIN tbAccounts ON (tbUsers.account = tbAccounts.id)
LEFT JOIN tbDirectory ON (tbUsers.account = tbDirectory.account)
LEFT JOIN coupon ON (tbUsers.account = coupon.account)
Keep in mind I want to show all records that appear in the table tbUsers with any related information in the tables tbAccounts, tbDirectory and Coupon.
If I omit the last two LEFT JOIN statements and some of the field names, the query works. No matter what I try, commas, ANDs ORs I can't get it to work with more than one LEFT JOIN.
I tried to duplicate my efforts in MS Access using it's query tool and it produces a query that uses RIGHT JOIN sytax. Unfortuntately, this query doesn't work in MySQL where I need it to.
This is by far the best tutorial I've read yet on general query syntax, thanks. If you can help, please let me know.
Speaking SQL (part 2)
Speaking SQL \(part 2\)
After learning how to insert and edit data in a database, the second part of our SQL tutorial takes an in-depth look at the SELECT query,and explains how to use joins, sub-queries and built-in functions to focus in on the data you need.
Please discuss this article in this thread. You can read the article here .