#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0

    Displaying Stars Without Voting


    Hello Everyone,

    I'm new to Mysql and creating a simple project. I've created a table called musicCD and stored some data such as song name, artist and rating.
    Here's what the code look like

    CREATE TABLE musicCD(
    Song VARCHAR(30),
    Artist VARCHAR(30),
    Rating INT,
    Primary Key(Song,Artist)


    INSERT INTO musicCD VALUES('Stan', 'Eminem', 4);


    I've rated each song from 0 to 5, so when I do
    SELECT Song, Artist, Rating
    FROM musicCD;

    It'll print the song, artist, and the ratings as below
    Song Artist Rating
    Stan Eminem 4

    How will I force this program to display 4 starts rather than number 4 or as many as the number of ratings?

    Thanks for any help..
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,178
    Rep Power
    4274
    Originally Posted by lampardd
    How will I force this program to display 4 starts
    presumably you meant 4 stars, not starts
    Code:
    SELECT Song
         , Artist
         , LEFT('*****',Rating) AS stars
     FROM musicCD;
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0
    Originally Posted by r937
    presumably you meant 4 stars, not starts
    Code:
    SELECT Song
         , Artist
         , LEFT('*****',Rating) AS stars
     FROM musicCD;
    Yes, I meant stars. Thanks a lot for the help.

IMN logo majestic logo threadwatch logo seochat tools logo