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

    Join Date
    Jan 2013
    Posts
    1
    Rep Power
    0

    Query doesn't work locally in browsers


    I have a website built with php and MySQL. On it I have a query that works well online on my web hotel, it works well locally in MySQL workbench and MySQL Administrator, but it won't give me any results in any of my browsers. I just can't understand why, and it's really frustrating. I don't get any error messages, all I get is a blank page. The query in question:

    Code:
    SELECT t1.final_artist_rating, artist.*, year(artist.deathdate) AS death_date, album.*, album.sha1_id_album, album_rating.final_rating, year(album.date) AS release_year, t1.artistid, t1.date, t1.trend_difference, t1.final_artist_rating_trend
    	FROM artist, album, album_rating, rec_artist_rating AS t1 
    		JOIN
    		( 
    		SELECT artistid, max(date) AS max_date
    				FROM rec_artist_rating
    					WHERE year(date) <= 2013
    				GROUP BY artistid 
    		) AS t2
    		ON t1.artistid = t2.artistid
    			AND t1.date = t2.max_date
    	WHERE artist.artistid = t1.artistid
    		AND album.albumid = t1.albumid
    		AND album_rating.album_id = t1.albumid
    		AND t1.final_artist_rating IS NOT NULL
    	GROUP BY t1.artistid
    	ORDER BY t1.final_artist_rating DESC, title DESC
    	LIMIT 500
    If I add the line "AND year(date) >= 2013 - 3" before GROUP BY in the subquery it works properly, which makes me think that it is some kind of a timeout thing, but I have no idea how to solve it.

    Does anyone have any suggestions? It would be greatly appreciated.

    /Mikael

    (I'm new to this forum, so if I've made some kind of rookie mistake I apologise.)
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,172
    Rep Power
    4274
    Originally Posted by ihwar2000
    ... it works well locally in MySQL workbench and MySQL Administrator, but it won't give me any results in any of my browsers.
    i would expect, then, that it's a problem with your application code

    what are you using, php?

    (note: browsers themselves don't execute mysql queries, it's always the server-side application code)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo