Jump to content

grouped, ordered and limited on same command -- need help


reilabrador

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.