reilabrador Posted July 4, 2008 Share Posted July 4, 2008 I need help. Consider the database: char | num a | 1 b | 3 a | 4 b | 2 b | 4 d | 2 d | 1 c | 1 a | 2 I want to get a limited list for 2 ordered charaters: a | 1 a | 4 a | 2 b | 3 b | 2 b | 4 On same command, I need to limit the counter characters, for example: LIMIT 1, 3 may be result: b | 3 b | 2 b | 4 c | 1 d | 2 d | 1 Who is the mysql command to do this? Any help? Quote Link to comment Share on other sites More sharing options...
fenway Posted July 6, 2008 Share Posted July 6, 2008 Well, you'll need to group by char (terrible column name, btw), and figure out what the first two are. Quote Link to comment Share on other sites More sharing options...
reilabrador Posted July 8, 2008 Author Share Posted July 8, 2008 What I need is to minimize the hits of mysqld. In the list above is a example that I have on my table and I need to show the elements by groups and the groups by pagination (using LIMIT X, Y). On this moment, I have about 3 or 4 access of mysqld to extract that final list, it begins with a list of limited groups available and finally ordered with the elements involved. Initially the source went well but now there are more visitors to consult the list and mysqld obliges us to wait 14s per limit of hits. So I am trying to improve the source and make it needed only a single access. As a example of table above explained, I need to limit the groups (letters, names, strings) with elements involved (numbers as units, dimensions, etc) Then, with the command [liMIT 0, 2], the list may show all elemens of the letter's group 'a' and 'b'. If [liIMT 2, 2] the list may show 'c' and 'd'. Other example, if [liIMT 1, 3], the list may show 'b', 'c', and 'd'. I think is possible only one mysql's command, but I'm not a advanced programmer. Unfortunatelly I have one table, I can't separate it in sub-tables. Best regards and thanks for helping me. Quote Link to comment Share on other sites More sharing options...
fenway Posted July 9, 2008 Share Posted July 9, 2008 Like I said, get the unique, ordered list of letters, and limit that -- if used in a derived table, you can join that back to whatever you want. 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.