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

[eluser]Leon Stafford[/eluser]
[quote author="jedd" date="1245271320"]Howdi,

I can see what you're doing, but I can't be sure that I know what you're trying to do. Can you throw together an example of input and what output you would expect from that. It looks like a really simple LEFT JOIN is required .. but immersing myself in other people's nomenclature also makes my brain melt .. so want to be sure it's for a good cause Wink

Like Fuzzy, I'll throw in a freebie to whet your appetite. Replace your first bit with this (yes, I know you're going to replace it all ... but for future reference)

Code:
function get_word_list($level = 1, $isShuffled = false)  {
    $user = $this->db_session->userdata('id');

    $qstring = "SELECT *
                FROM kg_compounds
                WHERE grade='$level'";

    if ($isShuffled)
        $qstring .= " ORDER BY RAND()";

    $query = $this->db->query($qstring);
[/quote]

Thanks Jedd,

I think I should sacrifice my own brain, get off my butt and study SQL again Tongue

I will post back if JOIN won't work and include some IO data.

It's basically for a learning system where known words get marked against a user name in the kg_progress table.

Starting a quiz using this code, it grabs all the words for a level, then looks in the progress table to see if any of the words are in there, if they are, it leaves them out...


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