mp3files table MySQL examples

mp3files table MySQL examples

Table Of Contents

MySQL Command Line syntax examples

MySQL man pages

MySQL syntax examples

These examples show a number of MySQL operations using MySQL and a single table. The examples include dumping the table using mysqldump and loading the table using mysql and the sql file created by the dump. The SQL examples inclde the simple syntax to show everything in the table followed by more complex examples inlcuding specifying fields, ordering the output, summerizing with group by, selecting subsets of the records with the where clause and the use of a subquery.

The examples end with the create table statement used to create the mp3files table with multiple indexes.

MySQL Command Line syntax examples

A - Dump the mp3files table without create database entries
Command Line Statement
mysqldump --user=<user> --no-create-db --add-drop-table \
--result-file=mp3files.sql lam mp3files

Back to Table Of Contents

B - The resulting sql file is less than 1 MB.
Command Line Statement
$ ll -h /tmp/mp3files.sql
-rw-rw-r-- 1 murakami staff 862K 2013-04-17 22:44 /tmp/mp3files.sql

Back to Table Of Contents

C - Transfer the file to the current machine.
Command Line Statement
cd /tmp
scp demeter.arsc.edu:/tmp/mp3files.sql .

Back to Table Of Contents

D - Load the mp3files table into another database
Command Line Statement
mysql -P 3306 -h dbprode.arsc.edu -u murakami cookbook -p  < /tmp/mp3files.sql

Back to Table Of Contents

MySQL syntax examples

00 - Show MySQL version and some other values
SQL Statement
select version(), ' ', user(), ' ', current_date(), ' ', now(), ' ', 1 + 1, ' ', pi();
version()



user()



current_date()



now()



1 + 1



pi()

5.1.55 lam@localhost 2013-04-17 2013-04-17 11:36:29 2 3.141593

1 of 1 rows displayed.

01 - Everything in the mp3files table
SQL Statement
select * from mp3files;
ARTIST

TITLE

ALBUM

TRACK

YEAR

GENRE

FILE

SIZE

DATE_TIME

TIME_STAMP

Led Zeppelin Black Dog Led Zeppelin IV 1 1971 Rock /mnt/ts/Music/Led-Zeppelin_Led-Zeppelin-IV/Black Dog.mp3 7265004 2009-03-19 15:01:41 2009-07-16 23:51:05
Led Zeppelin Four Sticks Led Zeppelin IV 6 1971 Rock /mnt/ts/Music/Led-Zeppelin_Led-Zeppelin-IV/Four Sticks.mp3 7665375 2009-03-19 15:01:42 2009-07-16 23:51:05
Led Zeppelin Going To California Led Zeppelin IV 7 1971 Rock /mnt/ts/Music/Led-Zeppelin_Led-Zeppelin-IV/Going To California.mp3 5347728 2009-03-19 15:01:42 2009-07-16 23:51:05
Led Zeppelin Misty Mountain Hop Led Zeppelin IV 5 1971 Rock /mnt/ts/Music/Led-Zeppelin_Led-Zeppelin-IV/Misty Mountain Hop.mp3 7242650 2009-03-19 15:01:42 2009-07-16 23:51:05
Led Zeppelin Rock And Roll Led Zeppelin IV 2 1971 Rock /mnt/ts/Music/Led-Zeppelin_Led-Zeppelin-IV/Rock And Roll.mp3 5411237 2009-03-19 15:01:42 2009-07-16 23:51:05
Led Zeppelin Stairway To Heaven Led Zeppelin IV 4 1971 Rock /mnt/ts/Music/Led-Zeppelin_Led-Zeppelin-IV/Stairway To Heaven.mp3 11922529 2009-03-19 15:01:42 2009-07-16 23:51:05
Led Zeppelin The Battle Of Evermore Led Zeppelin IV 3 1971 Rock /mnt/ts/Music/Led-Zeppelin_Led-Zeppelin-IV/The Battle Of Evermore.mp3 9314806 2009-03-19 15:01:43 2009-07-16 23:51:05
Led Zeppelin When The Levee Breaks Led Zeppelin IV 8 1971 Rock /mnt/ts/Music/Led-Zeppelin_Led-Zeppelin-IV/When The Levee Breaks.mp3 11697628 2009-03-19 15:01:43 2009-07-16 23:51:05
Moody Blues, The Dawn - Dawn Is A Feeling Days of Future Passed 02/07 1967 Rock /mnt/ts/Music/Moody-Blues_Days-of-Future-Passed/Dawn - Dawn Is A Feeling.mp3 5736738 2009-07-16 23:19:36 2009-07-16 23:51:05
Moody Blues, The Evening - a) The Sun Set, b) Twilight Time Days of Future Passed 06/07 1967 Rock /mnt/ts/Music/Moody-Blues_Days-of-Future-Passed/Evening - a) The Sun Set, b) Twilight Time.mp3 10257755 2009-07-16 23:19:36 2009-07-16 23:51:05
Moody Blues, The Lunch Break - Peak Hour Days of Future Passed 04/07 1967 Rock /mnt/ts/Music/Moody-Blues_Days-of-Future-Passed/Lunch Break - Peak Hour.mp3 8302528 2009-07-16 23:19:36 2009-07-16 23:51:05
Moody Blues, The The Afternoon - a) Forever Afternoon (Tuesday?), b) (Evening) Ti Days of Future Passed 05/07 1967 Rock /mnt/ts/Music/Moody-Blues_Days-of-Future-Passed/The Afternoon - a) Forever Afternoon (Tuesday ), b) (Evening) Time to Get Away.mp3 12763675 2009-07-16 23:19:36 2009-07-16 23:51:05
Moody Blues, The The Day Begins Days of Future Passed 01/07 1967 Rock /mnt/ts/Music/Moody-Blues_Days-of-Future-Passed/The Day Begins.mp3 8984285 2009-07-16 23:19:36 2009-07-16 23:51:05
Moody Blues, The The Morning - Another Morning Days of Future Passed 03/07 1967 Rock /mnt/ts/Music/Moody-Blues_Days-of-Future-Passed/The Morning - Another Morning.mp3 5867828 2009-07-16 23:19:36 2009-07-16 23:51:05
Moody Blues, The The Night - Nights In White Satin Days of Future Passed 07/07 1967 Rock /mnt/ts/Music/Moody-Blues_Days-of-Future-Passed/The Night - Nights In White Satin.mp3 10596895 2009-07-16 23:19:36 2009-07-16 23:51:05
ZZ Top 2000 Blues Recycler 8 1990 Rock /mnt/ts/Music/ZZ-Top_Recycler/2000 Blues.mp3 6447594 2009-03-19 15:01:43 2009-07-16 23:51:05
ZZ Top Burger Man Recycler 9 1990 Rock /mnt/ts/Music/ZZ-Top_Recycler/Burger Man.mp3 3922575 2009-03-19 15:01:44 2009-07-16 23:51:05
ZZ Top Concrete And Steel Recycler 1 1990 Rock /mnt/ts/Music/ZZ-Top_Recycler/Concrete And Steel.mp3 4901085 2009-03-19 15:01:44 2009-07-16 23:51:05
ZZ Top Decision Or Collision Recycler 6 1990 Rock /mnt/ts/Music/ZZ-Top_Recycler/Decision Or Collision.mp3 5290446 2009-03-19 15:01:44 2009-07-16 23:51:05
ZZ Top Doubleback Recycler 10 1990 Rock /mnt/ts/Music/ZZ-Top_Recycler/Doubleback.mp3 4923351 2009-03-19 15:01:45 2009-07-16 23:51:05

First 20 of 4331 rows displayed.

02 - Selected fields in the mp3files table orderd by track
SQL Statement
select ARTIST, ALBUM, TITLE, TRACK from mp3files
order by ARTIST, ALBUM, TRACK;
ARTIST

ALBUM

TITLE

TRACK

Adam Hood 6th Street Tuesday Night 1
Adam Hood 6th Street Million Miles Away 2
Adam Hood 6th Street Play Something We Know 4
Aerosmith Greatest Hits Dream On 01/10
Aerosmith Greatest Hits Same Old Song And Dance 02/10
Aerosmith Greatest Hits Sweet Emotion 03/10
Aerosmith Greatest Hits Walk This Way 04/10
Aerosmith Greatest Hits Last Child 05/10
Aerosmith Greatest Hits Back In The Saddle 06/10
Aerosmith Greatest Hits Draw The Line 07/10
Aerosmith Greatest Hits Kings And Queens 08/10
Aerosmith Greatest Hits Come Together 09/10
Aerosmith Greatest Hits Remember (Walking In The Sand) 10/10
Al Stewart Last Days Of The Century Last Days Of The Century 01/12
Al Stewart Last Days Of The Century Real And Unreal 02/12
Al Stewart Last Days Of The Century King Of Portugal 03/12
Al Stewart Last Days Of The Century Red Toupée 04/12
Al Stewart Last Days Of The Century Where Are They Now 05/12
Al Stewart Last Days Of The Century Bad Reputation 06/12
Al Stewart Last Days Of The Century Josephine Baker 07/12

First 20 of 4331 rows displayed.

03 - Summary of albums with title count from mp3files
SQL Statement
select ARTIST, ALBUM, count(TITLE) from mp3files
 group by ARTIST, ALBUM order by ARTIST, ALBUM;
ARTIST

ALBUM

count(TITLE)

Adam Hood 6th Street 3
Aerosmith Greatest Hits 10
Al Stewart Last Days Of The Century 12
Al Stewart The Best of Al Stewart 11
Alex de Grassi Windham Hill - The First Ten Years (1 of 2) 2
Alice Cooper School's Out 9
Allman Brothers Band, The Martin Scorsese Presents the Blues: The Allman Brothers 11
Allman Brothers Band, The One Way Out - Live At The Beacon Theatre - Disc 1 9
Allman Brothers Band, The One Way Out - Live At The Beacon Theatre - Disc 2 9
Allman Brothers Band, The Stand Back: The Anthology 16
Allman Brothers Band, The Stand Back: The Anthology - Disc 2 16
Allman Brothers Band, The Where It All Begins 10
Anders, Laguna & Ginsberg Laguna Tunes 1
Asphalt Ballet Tuesday's Rain 2
Bad Company 10 From 6 10
Bad Company Company of Strangers 13
Bad Company Here Comes Trouble 11
Bad Company Holy Water 13
Bad Company Run With The Pack 10
Bad Company Stories Told & Untold 14

First 20 of 451 rows displayed.

04 - Summary of Albums from mp3files for a particular artist
SQL Statement
select ARTIST, ALBUM, count(TITLE) from mp3files
 where ARTIST = 'Bad Company'
 group by ARTIST, ALBUM order by ARTIST, ALBUM;
ARTIST

ALBUM

count(TITLE)

Bad Company 10 From 6 10
Bad Company Company of Strangers 13
Bad Company Here Comes Trouble 11
Bad Company Holy Water 13
Bad Company Run With The Pack 10
Bad Company Stories Told & Untold 14
Bad Company Straight Shooter 8
Bad Company Swan Song 8

8 of 8 rows displayed.

05 - Tracks by Track number from mp3files for a particular album
SQL Statement
select ARTIST, ALBUM, TRACK, TITLE from mp3files
 where ARTIST = 'Bad Company'
 and ALBUM = 'Here Comes Trouble'
 order by TRACK;
ARTIST

ALBUM

TRACK

TITLE

Bad Company Here Comes Trouble 01/11 How About That
Bad Company Here Comes Trouble 02/11 Stranger Than Fiction
Bad Company Here Comes Trouble 03/11 Here Comes Trouble
Bad Company Here Comes Trouble 04/11 This Could Be The One
Bad Company Here Comes Trouble 05/11 Both Feet In The Water
Bad Company Here Comes Trouble 06/11 Take This Town
Bad Company Here Comes Trouble 07/11 What About You
Bad Company Here Comes Trouble 08/11 Little Angel
Bad Company Here Comes Trouble 09/11 Hold On To My Heart
Bad Company Here Comes Trouble 10/11 Brokenhearted
Bad Company Here Comes Trouble 11/11 My Only One

11 of 11 rows displayed.

06 - Summary of Albums for an artist using a subquery
SQL Statement
select ARTIST, count(ALBUM) as Albums from
  (select ARTIST, ALBUM from mp3files
  group by ARTIST, ALBUM order by ARTIST, ALBUM)
  as artist_album
 group by ARTIST;
ARTIST

Albums

Adam Hood 1
Aerosmith 1
Al Stewart 2
Alex de Grassi 1
Alice Cooper 1
Allman Brothers Band, The 6
Anders, Laguna & Ginsberg 1
Asphalt Ballet 1
Bad Company 8
Beatles, The 5
Big Kid 1
Bill Medley 1
Bill Quist 1
Billy Joel 1
Blondie 1
Blues Brothers, The 1
Bob Seger 1
Bobby Bloom, Sissy Spacek, Meco, The Tradewinds, Irving Spice St 1
Boston 2
Bow Wow Wow 1
Bruce Hornsby & The Range 1
Bryan Adams 2
Carbon Leaf 1
Carey Ott 1
Cars, The 4
Cheap Trick 1
Chicago 6
Clark Country 1
Cream 1
Creedence Clearwater Revival 3
Cyndi Lauper 5
Dana & Gene 1
Dana & Gene (With Ellie Greenwich) 1
Daniel Hecht 1
Darlene Love And The Blossoms 1
Dave Matthews Band 1
David Qualey 1
Deana Carter 1
Depeche Mode 1
Dire Straits 2
Dizzy X 1
Don McLean 2
Doobie Brothers, The 2
Doors, The 8
Duran Duran 1
Eagles 2
Echo & The Bunnymen 2
Elton John 10
Emerson, Lake & Palmer 2
Eric Clapton 2
Eugene Edwards 1
Fleetwood Mac 10
Frank Zappa 5
Freakhouse 1
friends of lizzy 1
Gabriel Mann 1
Gandalf 1
Genesis 1
George Thorogood 1
George Winston 1
Glenn Frey 2
Go Go's 1
Golden Earring 2
Grateful Dead 13
Greencards, The 1
Greg Graffin (Bad Religion) & Joan Jett And The Blackhearts 1
Guy Forsyth 1
Heart 9
Hooters 1
Huey Lewis And The News 1
Iggy Pop 3
Interior 1
INXS 3
Iron Butterfly 4
Iron Maiden 4
Isham, Mark 1
J. Geils Band, The 1
Jackson Browne 1
James Gang 2
Janis Joplin 2
Jeff Black 1
Jethro Tull 2
Jim Croce 1
Jimmy Buffett 14
Joan Baez 1
Joan Jett 1
Joan Jett & The Blackhearts (With The Beach Boys & Darlene Love) 1
Joe Satriani 1
Joe Walsh 4
Journey 3
Kacy Crowley 2
Kenny Laguna 1
Kimmie Rhodes 1
Kimmie Rhodes & Willie Nelson 1
Kinks, The 11
Kiss 1
Kissinger 2
Knack, The 1
Led Zeppelin 5
Levinhurst 1
Lil' Cap'n Travis 1
Little Roger And The Goosebumps 1
Liz Story 1
Love's Heart (Darlene Love) 1
Lynyrd Skynyrd 3
Madison Park 2
Madonna 7
Malcolm Dalglish 1
Marcy Playground 1
Mark Isham 1
Marshall Tucker Band 1
Mas Rapido 1
Matchbox 20 1
Meat Loaf 2
Men At Work 3
Michael Hedges 1
Michael Manring 1
Mike and The Mechanics 1
Mike Marshall & Darol Anger 1
Money, Eddie 1
Montreux 1
Moody Blues, The 3
Moose And The Pelicans 1
Morticians 1
Motley Crue 5
Musicmatch 1
Nickel Creek 1
Nightnoise 1
Oingo Boingo 1
Omar 1
Orange Peels 1
Outlaws, The 2
Ozark Mountain Daredevils 1
Ozzy Osbourne 3
Pat Benatar 5
Patsy Cline 1
Paul & Linda McCartney 1
Paul McCartney 3
Paul McCartney and Wings 1
Paula Abdul 1
Perfect Project 1
Peter Frampton 2
Peter Weinstock 1
Phil Collins 1
Philip Aaberg 1
Pink Floyd 6
Police, The 3
Pushmonkey 1
Queen 4
Rachel Loy 1
REO Speedwagon 1
Rick Wakeman 1
Robbie Basho 1
Rolling Stones 22
Santana 2
Sara Craig 1
Schonherz & Scott 1
Scott Cossu 1
Scott Cossu & Eugene Friesen 1
Shadowfax 2
Simon & Garfunkel 1
Spencer Barefoot 1
Spitballs 1
Starship 2
Steel Pulse 1
Steely Dan 2
Stein & Walder 1
Stephen Stills 1
Steppenwolf 4
Steve Gibbons Band 1
Steve Miller Band, The 1
Stray Cats 2
Styx 6
Supertramp 4
Talking Heads 4
Ted Nugent 2
Ten Years After 1
Thin Lizzy 3
Thomas Cunningham 1
Thompson Twins 1
Three Dog Night 6
Tim Story 1
Tom Petty 2
Tom Petty & the Heartbreakers 1
Tony Orlando And Wind 1
Traffic 6
Traveling Wilburys 2
Tremolo 1
UB40 1
Van Halen 11
Van Morrison 10
Von Iva 1
W.A. Mathieu 1
Wang Chung 1
White Hassle 1
William Ackerman 2
Wim Mertens 1
Wind 1
ZZ TOP 2

199 of 199 rows displayed.

07 - Show mp3files create table statement
SQL Statement
show create table mp3files;
Table

Create Table

mp3files
CREATE TABLE `mp3files` (
  `ARTIST` varchar(64) DEFAULT NULL,
  `TITLE` varchar(64) DEFAULT NULL,
  `ALBUM` varchar(64) DEFAULT NULL,
  `TRACK` varchar(8) DEFAULT NULL,
  `YEAR` varchar(4) DEFAULT NULL,
  `GENRE` varchar(32) DEFAULT NULL,
  `FILE` varchar(255) DEFAULT NULL,
  `SIZE` int(10) unsigned DEFAULT NULL,
  `DATE_TIME` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `TIME_STAMP` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  KEY `mp3files_by_ARTIST_ALBUM` (`ARTIST`,`ALBUM`,`TITLE`,`TRACK`),
  KEY `mp3files_by_ARTIST_TITLE` (`ARTIST`,`TITLE`),
  KEY `mp3files_by_DATE_TIME` (`DATE_TIME`,`ARTIST`,`ALBUM`,`TITLE`,`TRACK`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8

1 of 1 rows displayed.


165 visits (1 today, 1 this week, 22 this month, 165 this year)
Uptime: 03:01:45 up 4 days, 8:45, 3 users, load average: 0.00, 0.01, 0.00
3.141.47.139 GET from server z.larrymurakami.com

Sunday, December 22, 2024 @ 3:01:45 AM
z.ServerAdmin@lam1.us