18 Manipulating
select artist, min(year), max(year), count(album) from albums group by artist
Our Abba albums came out between 1974 and 1980. Our Alice Cooper albums came out
between 1971 and 2003, and there were 22 of them.
Who do we have the most albums of? We can give any function a name and than sort by
that name.
select artist, count(album) as albumcount from albums group by artist order
by albumcount desc, artist
Alice Cooper and Elton John top the list at 22 and 21 albums, respectively. That  desc  means
descending. By default, sorting goes from least to greatest. When we specify desc it will go from
greatest to least. In this case, it puts the artists with the most albums on top of the list.
Replacing text
Sometimes you'll want to replace text inside of other text. You'll use the  update  statement
for this as well, using the body() function. For example, if you want to replace all occurrences
of  Beetles  in your album names with  Beatles , whether the word occurs on its own or
inside some title such as  The Beetles at Carnegie Hall , you would do this:
update albums set album=replace(album, "Beetles", "Beatles")
Since there is no where portion of the statement, this will affect all records in the albums
table.




  

Home

About Services Network Support FAQ Order Contact
 

Php MySQL Web Hosting

Our partners:Jsp Web Hosting Unlimited Web Hosting Cheapest Web Hosting  Java Web Hosting Web Templates Best Web Templates PHP Mysql Web Hosting Interland Web Hosting Cheap Web Hosting PHP Web Hosting Tomcat Web Hosting Quality Web Hosting Best Web Hosting  Mac Web Hosting 

Lunarwebhost.net  Business web hosting division of Vision Web Hosting Inc. All rights reserved