Welcome Guest, Not a member yet? Register   Sign In
[CI 2.0] Incorrect query result. (Solved'
#1

[eluser]DirkZz[/eluser]
Hello everyone,

I'm currently stuck with on a project because im not getting the right results back from CodeIgniter.
I use the following query:

Code:
$this->database->select('P.Artikelnummer,P.Naam');
        $this->database->from('Type AS T');
        $this->database->join('ProductToestel AS PT', 'PT.ToestelID=T.ID');
        $this->database->join('Product AS P', 'P.Artikelnummer=PT.Artikelnummer');
        $this->database->where('P.GroepID', $iGroepID);
        $this->database->where('T.ID', $iType);
        $this->database->where_in('P.GroepID', $this->config->item('groepen'));
        $this->database->where_in('T.MerkID', $this->config->item('merken'));
        $this->database->order_by('P.Naam', SORTEER);
        $this->database->where('P.Prijs >', 0);

It returns 2 results,when I should get 4.
However when I echo the executed query it shows me this:

Code:
SELECT `P`.`Artikelnummer`, `P`.`Naam` FROM (`Type` AS T) JOIN `ProductToestel` AS PT ON `PT`.`ToestelID`=`T`.`ID` JOIN `Product` AS P ON `P`.`Artikelnummer`=`PT`.`Artikelnummer` WHERE `P`.`GroepID` = '1' AND `T`.`ID` = '2' AND `P`.`GroepID` IN (4, 30, 3, 53, 60, 84, 2, 177, 1, 17, 5, 7, 156, 51) AND `T`.`MerkID` IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) AND `P`.`Prijs` > 0 ORDER BY `P`.`Naam` ASC

And when I execute this query directly in PMA I get the 4 records I want.
So after I figured that out I tried to execute the query with the $this->db->query(); command but it still gave me only 2 records.

A I missing something? I've been staring at it for while, browsed the forums and the internet but I couldn't find a solution for this.

So I hope someone can help me out with this one,

Thanks in advance.




Theme © iAndrew 2016 - Forum software by © MyBB