JOIN function in SELECT
First, a little rant: I don't know what it is about the MySQL docs that make them so difficult for me to read, but try as I may, I have the most difficult time making heads or tails of anything in the official MySQL documentation. That being said, here's my question, the answer to which I was NOT able to glean from the MySQL docs: I have two tables, data and archive ... they have nearly identical columns except for data, which contains a couple of extra columns that are not considered important once the data is moved to the archive table. I need to pull data from two columns in both tables, based on the ENUM results of a third column, favorite, in each table. To wit, if the value of column favorite in both data and archive = 'Y', I need to pull it for display. $query = SELECT id, title FROM data, archive WHERE favorite = 'Y' doesn't cut it. Neither does SELECT data.id, data.title, archive.id, archive.title WHERE data.favorite = 'Y', archive.favorite = 'Y' Assistance, please? And can anyone recommend a good MySQL reference that's a little easier for a schlub like me to understand? Thanks, Bob Bob Sawyer --- Pixellated! Design:Develop:Deliver www.pixellated.org -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: JOIN function in SELECT
This is not really a MySQL docs problem. The manual gives the mysql syntax, but you are expected to already know SQL. You need to get a book on SQL. SELECT data.id, data.title FROM data,archive WHERE data.favorite=archive.favorite AND data.favorite='Y'; Bob Sawyer wrote: First, a little rant: I don't know what it is about the MySQL docs that make them so difficult for me to read, but try as I may, I have the most difficult time making heads or tails of anything in the official MySQL documentation. That being said, here's my question, the answer to which I was NOT able to glean from the MySQL docs: I have two tables, data and archive ... they have nearly identical columns except for data, which contains a couple of extra columns that are not considered important once the data is moved to the archive table. I need to pull data from two columns in both tables, based on the ENUM results of a third column, favorite, in each table. To wit, if the value of column favorite in both data and archive = 'Y', I need to pull it for display. $query = SELECT id, title FROM data, archive WHERE favorite = 'Y' doesn't cut it. Neither does SELECT data.id, data.title, archive.id, archive.title WHERE data.favorite = 'Y', archive.favorite = 'Y' Assistance, please? And can anyone recommend a good MySQL reference that's a little easier for a schlub like me to understand? Thanks, Bob Bob Sawyer --- Pixellated! Design:Develop:Deliver www.pixellated.org -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: JOIN function in SELECT
Thanks, Gerald. I appreciate the assist. As for the docs: I know it's not a docs problem, really - yet if you compare, say, the PHP docs with the MySQL docs, the PHP docs are much easier to read and the examples are clearer than in the MySQL docs - IMHO. I think it's unrealistic to expect anyone to be completely familiar with anything - be it PHP, SQL, or Spanish - before consulting the documentation. I've learned a great deal of PHP from the documentation alone. Unfortunately, I don't get the same results from the MySQL documentation. Cheers, Bob -Original Message- From: gerald_clark [mailto:[EMAIL PROTECTED] Sent: Monday, March 31, 2003 12:46 PM To: [EMAIL PROTECTED] Cc: MySQL List Subject: Re: JOIN function in SELECT This is not really a MySQL docs problem. The manual gives the mysql syntax, but you are expected to already know SQL. You need to get a book on SQL. SELECT data.id, data.title FROM data,archive WHERE data.favorite=archive.favorite AND data.favorite='Y'; Bob Sawyer wrote: First, a little rant: I don't know what it is about the MySQL docs that make them so difficult for me to read, but try as I may, I have the most difficult time making heads or tails of anything in the official MySQL documentation. That being said, here's my question, the answer to which I was NOT able to glean from the MySQL docs: I have two tables, data and archive ... they have nearly identical columns except for data, which contains a couple of extra columns that are not considered important once the data is moved to the archive table. I need to pull data from two columns in both tables, based on the ENUM results of a third column, favorite, in each table. To wit, if the value of column favorite in both data and archive = 'Y', I need to pull it for display. $query = SELECT id, title FROM data, archive WHERE favorite = 'Y' doesn't cut it. Neither does SELECT data.id, data.title, archive.id, archive.title WHERE data.favorite = 'Y', archive.favorite = 'Y' Assistance, please? And can anyone recommend a good MySQL reference that's a little easier for a schlub like me to understand? Thanks, Bob Bob Sawyer --- Pixellated! Design:Develop:Deliver www.pixellated.org -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]