JamesB Posted January 23, 2015 Share Posted January 23, 2015 Hey I can't seem to get this left join to work to retrieve the username from the users table. projects.external_project_user can be 0, with no users.user_id being 0. SELECTprojects.*,users.username AS external_project_username,(SELECT COUNT(*) FROM todo_entries WHERE todo_entries.project_id = projects.project_id AND status = 1) AS entry_count_open,(SELECT COUNT(*) FROM todo_entries WHERE todo_entries.project_id = projects.project_id AND status = 2) AS entry_count_pending_testing,(SELECT COUNT(*) FROM todo_entries WHERE todo_entries.project_id = projects.project_id AND status = 3) AS entry_count_resolved,(SELECT COUNT(*) FROM todo_entries WHERE todo_entries.project_id = projects.project_id AND status = 4) AS entry_count_skippedFROM projectsLEFT JOIN usersON users.user_id = projects.external_project_userWHERE projects.todo_listed = 1ORDER BY `order` DESC Link to comment Share on other sites More sharing options...
justsomeguy Posted January 24, 2015 Share Posted January 24, 2015 What happens when you run that? Link to comment Share on other sites More sharing options...
JamesB Posted January 24, 2015 Author Share Posted January 24, 2015 This project tracker is hosted here for <?php htmlspecialchars($project->external_project_username); ?>. So the query was fine, turns out I'd forgotten the word echo lol. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now