I have two tables that I would like to JOIN. I'd like to perform an INNER JOIN for these two tables to get the result that I want but it does not seem to be working. Everytime I run the query, I just get a loading... notification that takes too long to display and then after several minutes, I get this message:
Error in Processing Request. Error Code 500. Internal Server Error.
Basically I would want to get a result in this format:
- Name Surname, Phone number
- List(s) subscribed to (subscriber status) - date subscribed.
ex.) Desired Result:
Jane Doe, 082 980 9514
Home Loan Applications (Active) - 17/07/2013
Credit Report (Free Report) (Unsubscribed) 12/06/2013
Here's the link to the sample tables:
Tables
You'll notice there that Jane Doe has subscribed to two lists (Home Loan Applications and Credit Report) so the two lists are listed in the result. Then, she already unsubscribed to credit report that's why there's (unsubscribed) next to it.
This is the SQL statement that I used:
SELECT emailaddress, subscribedate, unsubscribed
FROM `interspire_subscriber`
INNER JOIN `interspire_customfield` ON interspire_subscriber.subscriberid =
interspire_customfield.subscriberid
I don't know why I get the error. Is there a way to achieve this using only mySQL? or what else would I do in PHP to get this?
The script also seems too slow to execute because of the 76,000+ records.
Update: As suggested, I have set the subscriberids on both tables as index and the query worked fine. Currently I use this mysql statement:
SELECT interspire_customfield.subscriberid, interspire_customfield.fname,
interspire_customfield.lname, interspire_customfield.phone, emailaddress,
subscribedate, unsubscribed, interspire_customfield.listid, listname
FROM`interspire_subscriber` INNER JOIN `interspire_customfield` ON
interspire_subscriber.subscriberid = interspire_customfield.subscriberid
but it still does not list down all the lists that the user is subscribed to.
Copyright License:
Author:「maikelsabido」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/19485537/what-is-the-proper-mysql-statement-that-i-should-use-for-more-than-76-000-record