0

I have following query,

SELECT t_subject.subject, SUM( t_skilllist.skill_level ) AS total_skill, t_users.first_name, 

t_skilllist.skill_level
FROM  `t_skilllist` 
JOIN t_subject ON t_subject.id = t_skilllist.subject_id
JOIN t_users ON t_users.id = t_skilllist.user_id
WHERE t_subject.subject =  'html'
GROUP BY t_users.first_name
ORDER BY total_skill DESC 
LIMIT 0 , 30

I want to display subject and skill level for each student. But, for one subject I can do that with above query. As an example for html it works. However, I want to pass more than one subject to the query dynamically. I tried to combined subjects with AND operator but it return empty result set.

How to solve this? How to pass more than two subjects to the query? I am using PHP as server side scripting language.

1
  • 1
    use OR instead of AND Commented Jul 4, 2013 at 10:29

1 Answer 1

2

You can use the IN() clause.

WHERE t_subject.subject IN ('html', 'php', 'and', 'a', 'lot', 'more')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.