Need mysql statement help - Joomla! Forum - community, help and support


hi,

i know enough mysql know existence of various ways of making compound queries join statments , such, don't know enough figure out how it... i'm looking figuring out best way set query uses 3 interdependent tables.

here statements i've got:

code: select all

select `fvalue` `jos_juser_extended_data` `field_id` = '1' , `user_id` = '$user->id'

select `surveyls_survey_id` `lime_surveys_languagesettings` `surveyls_title` = `fvalue`

select `token` `lime_tokens_x` `completed` = 'y'


in last statement, 'x' in 'lime_tokens_x' value 'surveyls_survey_id' in previous statement.

what i'm wanting end know whether logged in user has completed survey, need end count of "y" in field "completed" of "lime_tokens_x" table - because if it's > 0, it's been completed.

any suggestions best way structure this?

thanks,
scott

hi scott,

if tables interdependent, field have in common? instance, if have userid field maps 1 in first query, can use join. in case you'd have this:

code: select all

select `a.fvalue`,`b.surveyls_survey_id`,`c.token`
  `jos_juser_extended_data` a
join `lime_surveys_languagesettings` b
  on `a.user_id`=`b.user_id`
join `lime_tokens_x`as c
  on `b.user_id`=`c.user_id
where `a.field_id` = '1'
  , `a.user_id` = '$user->id'
  , `b.surveyls_title` = `fvalue`
  , `c.completed` = 'y';


i'm bit confused `fvalue` is, though. sure we'll you, can make you've provided. didn't test above, way.

bruce





Comments

Popular posts from this blog

Problem with all comment components. - Joomla! Forum - community, help and support

Nogen der kender et simpelt hvidt template med topmenu kun - Joomla! Forum - community, help and support

adobe audition 1.5 multi track problems....