• Image 1
  • Image 2
  • Image 3
  • Image 4
  • Image 5
  • Image 6
  • Image 7




Thursday, September 20, 2012

GROUP BY IN MYSQL


Hello my friends.. you are on my blog at “We Are Knowledge”.. You was choice the right blog.. because this blog is blog containing science, so you must to read my this article and other article…

Now.. I still with tutorial about “MYSQL”, but with different discuss.. And I want giving you science about “GROUP BY IN MYSQL”. You do not know ?? let’s do read my article…


1. GROUP BY

Group by in mysql is syntax to categorize articles based on the name of the column that we choose. By using this syntax, we can prevent errors that would arise on queries that we have made, such as: the table not single-row.

Advantages of using this syntax is no record of the same printed again. If the record is the same it will be joined with the previous record

And this syntax “Group By” :

SELECT hardware.id_hardware, hardware.name_hardware, hardware.quantity_hardware, software.id_software, software.name_software, software.quantity_software
FROM hardware, software
WHERE hardware.id_hardware = software.id_software
GROUP BY id_software


Logic ::

Select

>> for to appear id hardware, name hardware, quantity hardware, id software, name software, quantity software


From

>> for show records that are on the table hardware and software


Where

>> this syntax to declare conditions, namely : display hardware id if the same hardware id id software


Group by

>> and the syntax is useful to classify the records that have been determined



To result :

id_
hardware
name_
hardware
quantity_
hardwar
id_
software
name_ software
quantity_
software
1
VGA
5
1
MYSQL
7
2
MEMORY
8
2
ORACLE
4
3
HARD DISK
4
3
SQL
9
4
DVD ROOM
4
4
XAMPP
5
5
PROCESSORS
5
5
SQL PLUS
6



2. WITH ROLLUP

This function is an additional function, and is useful for obtaining results or summing all items.

syntax “With Rollup” :

GROUP BY id_software WITH ROLLUP


And if we add this function become :


NULL
PROCESSORS
26
NULL
SQL PLUS
31



Ok.. Just it…
I hope you understand…
See you later

No comments:

Post a Comment