MichaelMackey Posted July 7, 2008 Share Posted July 7, 2008 Hi, heres my problem: I have 2 tables I'm joining together. The first table has user information such as their ID, name, etc. The second table has test results for these users, the users can have multiple test results and it is also possible they will have no test results. What determines if a user will have multiple test results is the year on the test (only one test result per user per year). What I'm trying to do is select a list of ALL of the users, and if it's applicable it will also show their result data. What I can't seem to figure out is how to select this data while ignoring the previous years data as well as ensuring all users are in the list even if they have no data. This is what I'm currently trying to work with: SELECT m.idcontestant, r.recognition FROM kn_contestant m LEFT JOIN kn_results_contestant r ON m.idcontestant = r.idcontestant WHERE (r.result_year = 2008 OR r.result_year IS NULL) Any help is appreciated, thanks. Mike Quote Link to comment Share on other sites More sharing options...
Barand Posted July 8, 2008 Share Posted July 8, 2008 SELECT m.idcontestant, r.recognition FROM kn_contestant m LEFT JOIN kn_results_contestant r ON m.idcontestant = r.idcontestant AND ((r.result_year = 2008) OR (r.result_year IS NULL)) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.