Click to See Complete Forum and Search --> : More MySQL Help Please?


XxMaCaBrExX
06-14-2001, 05:01 PM
I have a basic understanding of SQL, and I need to generate a report from a database. There is a SQL database named "live_data", in that database is a table named "leads". I need to extract from the "leads" table all records that have a date in the "PurchaseDate" field.

I need the following information for all records that have a "PurchaseDate":

"OfficeID"
"FirstContDate"
"FirstName"
"LastName"
"Source"
"PurchaseDate"
"PlanID"

I would also like to know how to do a SQL inner join. I need to join the "leads" with "offices" and get the office name (Offices.Name) instead of the "OfficeId". The two tables are related by the "OfficeId" field.

I've tried to explain what I need help with as best as I possibly can, but I'm still a beginner at all this funny database stuff. Please feel free to request more info if I left anything out that might be vital for you guys to be able to help me on this.
Thanks. :)

[ 14 June 2001: Message edited by: XxMaCaBrExX ]

XxMaCaBrExX
06-18-2001, 09:00 AM
Well, does anybody know somebody that could help me with this, or a website I can go to to read up on it a little? :)

andrzej
06-18-2001, 09:30 AM
1:


mysql> USE live_data;
mysql> SELECT * FROM leads WHERE PurchaseDate != "";


or:


mysql> SELECT * FROM leads WHERE PurchaseDate IS NOT NULL;



Only one of the above will be OK in your particular implementation.

2:

mysql> SELECT Offices.name FROM Offices, leads WHERE leads.OfficeID = Offices.OfficeID;


Hope that helps a bit.

Documentation: http://www.mysql.com/documentation/mysql/bychapter/