Need mysql statement help
Posted: Thu Jan 31, 2008 8:29 am
Hi,
I know enough about mysql to know about the existence of various ways of making compound queries with JOIN statments and such, but I don't know enough to figure out how to do it... so I'm looking for some help figuring out the best way to set up a query that uses three interdependent tables.
Here are the statements I've got:
In the last statement, the 'x' in 'lime_tokens_x' is the value from 'surveyls_survey_id' in the previous statement.
What I'm wanting to end up with is to know whether the logged in user has completed the survey, so I just need to end up with a count of "Y" in field "completed" of the "lime_tokens_x" table - because if it's > 0, then it's been completed.
Any suggestions for the best way to structure this?
Thanks,
Scott
I know enough about mysql to know about the existence of various ways of making compound queries with JOIN statments and such, but I don't know enough to figure out how to do it... so I'm looking for some help figuring out the best way to set up a query that uses three interdependent tables.
Here are the statements I've got:
Code: Select all
SELECT `fvalue` FROM `jos_juser_extended_data` WHERE `field_id` = '1' AND `user_id` = '$user->id'
SELECT `surveyls_survey_id` FROM `lime_surveys_languagesettings` WHERE `surveyls_title` = `fvalue`
SELECT `token` FROM `lime_tokens_x` WHERE `completed` = 'Y'
In the last statement, the 'x' in 'lime_tokens_x' is the value from 'surveyls_survey_id' in the previous statement.
What I'm wanting to end up with is to know whether the logged in user has completed the survey, so I just need to end up with a count of "Y" in field "completed" of the "lime_tokens_x" table - because if it's > 0, then it's been completed.
Any suggestions for the best way to structure this?
Thanks,
Scott