MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old February 15th, 2006, 03:11 PM
method method is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 54 method User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 45 m 12 sec
Reputation Power: 4
Arrow How to output part of feild using mysql

Hi all. i got a huge list of mp3 that they are in diffrent folders. I put all the songs infor in mysql database in a table called files. I want a query db that output foldernames for me .The folder name is part of feiled called filename in files table. The value of filename is like this stored in db :

http://localhost/wimpy5recursive/mp3s/album1/song1.mp3
http://localhost/wimpy5recursive/mp3s/album2/song4.mp3
where the bold part is the foldername. i want to print folder name.Note:mp3s is the root folder for mp3s.The whole point is to list all folders name and link to page that holds songs inside those folders.

Furthermore, i want a query all feilds info for songs in each given folder.What i mean is that for each folder it lists all songs info iside that folder.I want to be able to tell the query what folder i want to list its song.Thanks

Reply With Quote
  #2  
Old February 15th, 2006, 03:46 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
Are you storing the URL itself in the database?
You might want to consider storing the album and filename as two different fields, then truncate the values.

I have no faith in this code working, I suggest you take my first suggestion =)
Code:
SELECT SUBSTR(SUBSTR(filename,INSTR(filename,'/',1,5)), INSTR(filename, '/')) AS folder
FROM files
ORDER BY folder;
__________________
Daryl's Homepage | My Blogroll | My Profile | Firefox supporter!
DevArticles Forum Moderator

"The net is a waste of time, and that's exactly what's right about it." -- William Gibson

Reply With Quote
  #3  
Old February 15th, 2006, 04:02 PM
method method is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 54 method User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 45 m 12 sec
Reputation Power: 4
Arrow

Quote:
Originally Posted by MadCowDzz
Are you storing the URL itself in the database?
You might want to consider storing the album and filename as two different fields, then truncate the values.

I have no faith in this code working, I suggest you take my first suggestion =)
Code:
SELECT SUBSTR(SUBSTR(filename,INSTR(filename,'/',1,5)), INSTR(filename, '/')) AS folder
FROM files
ORDER BY folder;


Many thanks for u reply. well these are the fields in table :

Code:
filename|artist|album|title|track|comments|genre|s  econds|filesize|bitrate

I already have a query that list songs by album .I have huge list of mp3 in diffrent folders some of them are collections from diffrent artis and albums and some does not have good tags so i want create seperate page using a query that list folders for me and then link that page to another page that lists songs inside that folder.

I use this getid3 php script that uploads for me song info to above db.That script does not put the foldernames as seperate field and it is huge program and hard to edit.

Unfortunetly it give me the following error trying your code ;

Code:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1,5)), INSTR(filename, '/')) AS folder
FROM files
ORDER BY folder LIMIT 0, 30' at line 1 

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > How to output part of feild using mysql


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway