Welcome Guest, Not a member yet? Register   Sign In
JOIN Quistion
#1

[eluser]Callista[/eluser]
Hi

i'm using a join to connect 3 tables.

My content table
A connecting table between the pictures and the content
And a picture table

----

I need the ID of the first table in my view for an edit function.
BUT CI only gives me the ID if the second table is filled in. This is because the ID is used as forign key in the second table.

This second table wil not always be filled in, because the second table is for the pictures and not every text has pictures.

Because it's not always filled in CI reads NULL as ID when the second table isn't filled in.

----

So i found in my MySQL guide a solution for the join.

Code:
"SELECT *
FROM (`alinea`)
LEFT OUTER JOIN `image_koppel`
USING ( alinea_ID )
LEFT OUTER JOIN `image` ON `image_koppel`.`image_ID` = `image`.`image_ID`
WHERE `alinea`.`pagina_ID` = '1'
AND `alinea`.`alinea_status` =1
ORDER BY `alinea`.`alinea_volgorde` ASC";

JOIN '' USING

instead of

JOIN '' ON

----

does anybody know how i can write the statement above in CI style?
because i can't find it anywhere how i can produce JOIN '' USING in CI


(i hope i explained everything clearly)
#2

[eluser]bgreene[/eluser]
have you tried
select a.*, i.whatever from alinea a
left join image_koppel k on k.id = a.alinea_id
left join image i on i.id = k.image_id
where (a.pagina_id = 1) and (a.alinea_status = 1)
order by a.alinea_volgorde asc




Theme © iAndrew 2016 - Forum software by © MyBB