Mr_CHISOL Posted January 25, 2007 Share Posted January 25, 2007 Hello there!I'm working on a component for Joomla!, it's a "quote handler" (I'm tired right now, it's 2am here...).I'm listing all quotes in a list (table: jos_kacquotes) and getting the name of the category it belongs to (table: jos_kacquotes_categories) and the user who added the quote (table: jos_users).In a normal case I use a seperatet query (one for each row..) when I list the quotes to get the username.(It isn't the best, partially because of the whole "seperate data from layout"-thing, but that's not the point)I get the catagory in the same query as I get the quotes: SELECT a.*, b.cattitle FROM jos_kacquotes AS a LEFT JOIN jos_kacquotes_categories AS b ON b.id = a.categoryid ... But as I have added the abbility to sort by column, I need to include the user-table in that query to, and it's hete it gets tricky.Right now I have this query for that: SELECT DISTINCT a.*, b.name, c.cattitle FROM jos_kacquotes AS a LEFT JOIN jos_kacquotes_categories AS c, jos_users AS b ON b.id = a.createdby OR c.id = a.categoryid ORDER BY a.createdby_str, b.name DESC The problem with this query is that it returns "twin-rows" (each row twice).And I can't figure out how I'm going to make it work as I want...Thankfull for all ideas. Link to comment Share on other sites More sharing options...
Mr_CHISOL Posted January 27, 2007 Author Share Posted January 27, 2007 I solved it by using GROUPING BY.It works but I don't think it's an satisfying solution, but it works. 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