CodeIgniter Forums
INNER JOIN USING - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: INNER JOIN USING (/showthread.php?tid=76860)



INNER JOIN USING - stepgr - 06-27-2020

I have this in my normal query  :

INNER JOIN vehicles USING(idvehicles)

but  in active record using this :

$builder->join('vehicles', 'e.idvehicles = vehicles.idvehicles');

does not return the same results.
Reading the builder class there is a $type  in the join method but I dont think it has
nothing to do with my case.
Does that mean I have to use a raw query to get my results ? If yes this why there is
prepare and execute in running queries I read in documentation ?

I'm very new to all this pls  pardon my ignorance


RE: INNER JOIN USING - stepgr - 06-28-2020

Well to answer my own question  in case some other newbie falls into the same pit
I had to alter the statement  from
$builder->join('vehicles', 'e.idvehicles = vehicles.idvehicles');
to
$builder->join('vehicles', 'idvehicles', 'INNER');

also if your query returns more that one row you need to use wherein instead of  where
($builder->wherein instead of $builder->where)

I had to read the BaseBuilder.php  in order to get the info , the documentation is a bit
vague in this .

Thanks for a great tool though . If you need help with documentation  I would be willing to
help you folks.
Smile