Jump to content

MySQL GROUP BY is pretty awesome


sKunKbad

Recommended Posts

As a freelancer working alone, I've got to wear all the hats, doing all the front end and back end design and development. So perhaps I'm never really specializing in any one thing, and I tend to miss some good stuff, like MySQL GROUP BY. Doing counts of things using GROUP BY is very handy. I saw somebody doing that in a thread, and adapted it to two things that I was working on in the last week. Sweet!

 

What other fun MySQL stuff am I missing out on?

Link to comment
Share on other sites

Well, GROUP BY is a pretty standard SQL syntax that isn't specific to MySQL. If you were not aware of that, there's no telling what you are not familiar with: ORDER BY, LIMIT, etc.

 

The MySQL manual isn't as easy to digest as the PHP one is. You can go here: http://dev.mysql.com/doc/refman/5.0/en/functions.html

 

which is the base page for "functions". You can then select one of the links for areas such as "String Functions", "Data Functions", etc. You'll then get a list of functions in the selected area. Typically those pages have a list of the functions and a short description at the top of the page.

Link to comment
Share on other sites

Well, GROUP BY is a pretty standard SQL syntax that isn't specific to MySQL. If you were not aware of that, there's no telling what you are not familiar with: ORDER BY, LIMIT, etc.

 

The MySQL manual isn't as easy to digest as the PHP one is. You can go here: http://dev.mysql.com/doc/refman/5.0/en/functions.html

 

which is the base page for "functions". You can then select one of the links for areas such as "String Functions", "Data Functions", etc. You'll then get a list of functions in the selected area. Typically those pages have a list of the functions and a short description at the top of the page.

 

As you say, I'm sure it is pretty standard SQL syntax. I've used ORDER BY and LIMIT to do pagination many times, and I've also created and used stored procedures quite a bit. I've been working with MySQL for years, and I feel comfortable with using it, which happens every day actually. I have read a couple books on MySQL, but I think I have a habit of skimming over things I don't think I will use, and that's probably contributing to why I didn't see the usefulness of GROUP BY.

 

I really don't like the MySQL docs. PHP has great docs when compared to MySQL. Also, I like real world examples, which the docs don't have a lot of. That's why when I saw the usage of GROUP BY I was so pleased.

 

I have a lot of goals, and one is to have a more complete understanding of MySQL. For instance, I'm not really able to understand the usefulness of MySQL VIEWS.

Link to comment
Share on other sites

As you say, I'm sure it is pretty standard SQL syntax. I've used ORDER BY and LIMIT to do pagination many times, and I've also created and used stored procedures quite a bit. I've been working with MySQL for years,

 

Well, I'm surprised how someone could work with MySQL for years and not use GROUP BY. There are many basic features that require it. Well, I guess you could always query all the ungrouped records and then get the results by processing all the individual records in the code. But, my god, what a waste that would be.

 

Anyway, that is why I have a hard time telling you that function "X" is another one you would benefit from. GROUP BY is pretty pedestrian in my opinion. I would still suggest reading the names of the functions and their descriptions in the manual. You would then at least have an idea of what is available. Then, if you find a need for something, you can do the extra research to learn how to use it.

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.