Welcome Guest, Not a member yet? Register   Sign In
Help tuning a very poor SQL query
#10

[eluser]Leon Stafford[/eluser]
[quote author="jedd" date="1245278442"]Errors ...? Go on .. share them. Smile [/quote]

Hi jedd, thanks again.

The errors were from the JOIN ?? ON ?? line, basically the errors were as descriptive as me...

I used the ammendment for the shuffle here:

Code:
$query_string = "            
        SELECT *
        FROM kg_compounds
        WHERE NOT
        EXISTS (
            SELECT compound
            FROM kg_progress
            WHERE kg_progress.compound = kg_compounds.id AND
            (
            kg_progress.compound_progress =1 AND kg_progress.user = '$user'
            )
        
        )
        AND grade = '$level'
        
        
        
        ";

        if ($isShuffled)
        {
            $query_string .= " ORDER BY RAND()";
        }    
        $query_string .= " LIMIT 20";
            
        $query = $this->db->query($query_string);

I know I should implement the better random code as I've noticed that a lot on the forums.

And jedd, thanks for the LEFT JOIN sample, I think I should aim to migrate from the current solution to a JOIN for performance, right?


Messages In This Thread
Help tuning a very poor SQL query - by El Forum - 06-17-2009, 08:03 AM
Help tuning a very poor SQL query - by El Forum - 06-17-2009, 08:19 AM
Help tuning a very poor SQL query - by El Forum - 06-17-2009, 08:24 AM
Help tuning a very poor SQL query - by El Forum - 06-17-2009, 09:42 AM
Help tuning a very poor SQL query - by El Forum - 06-17-2009, 09:47 AM
Help tuning a very poor SQL query - by El Forum - 06-17-2009, 10:10 AM
Help tuning a very poor SQL query - by El Forum - 06-17-2009, 10:28 AM
Help tuning a very poor SQL query - by El Forum - 06-17-2009, 11:21 AM
Help tuning a very poor SQL query - by El Forum - 06-17-2009, 11:40 AM
Help tuning a very poor SQL query - by El Forum - 06-17-2009, 11:49 AM
Help tuning a very poor SQL query - by El Forum - 06-18-2009, 05:49 AM
Help tuning a very poor SQL query - by El Forum - 06-18-2009, 05:53 AM
Help tuning a very poor SQL query - by El Forum - 06-18-2009, 06:02 AM
Help tuning a very poor SQL query - by El Forum - 06-18-2009, 09:57 AM
Help tuning a very poor SQL query - by El Forum - 06-18-2009, 10:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB