tags:

views:

70

answers:

0

Hi all,

This is the query which prints all the records from artist table and corresponding rating to that specific artist. And this query displays the rated artist at top and others after that.

Now my prob is

I have included rating table in this query to get the ratings of the artist rated by the members in the site.

But how should i get the field name mem_id from rating table ?

I cant able to get any exact solution while googling.

Any help will be thankful and greatful.

SELECT  a.id, 
        a.name, 
        aa.artist_review, 
        aa.artist_description, 
        a.category, 
        IF((IF((SELECT count(*) FROM ratings WHERE a.id=rating_num)>1,true,1))=true,(SELECT AVG(rating_id)*100 FROM ratings WHERE a.id=rating_num),'0') as PER 
FROM    `artist` a LEFT JOIN 
        `artist_album` aa ON a.id = aa.fk1_artist_id 
WHERE   name LIKE 'Α%' 
ORDER   BY  CASE WHEN PER != '' THEN 1 ELSE 2 END , 
            PER

SORRY FOR MY ENGLISH