JavaCake
JavaCake

Reputation: 4115

SQL Join failing with CodeIgniter

Im trying to join two tables but cannot seem to figure out how to resolve this error: This is the code generated from CodeIgniter:

SELECT `proc`.* FROM (`deliverycheck_proc_entries` proc) 
LEFT OUTER JOIN `deliverycheck_proc_entries` 
ON `proc`.`raw_entry_id` = `deliverycheck_raw_entries`.`id` 
WHERE `proc`.`status` > '1' 
ORDER BY `id` asc LIMIT 10

My error:

Error Number: 1054
Unknown column 'deliverycheck_raw_entries.id' in 'on clause'

I need all the columns from deliverycheck_proc_entries and specific from deliverycheck_raw-entries.

Upvotes: 0

Views: 95

Answers (2)

juergen d
juergen d

Reputation: 204924

change

LEFT OUTER JOIN `deliverycheck_proc_entries` 

to

LEFT OUTER JOIN `deliverycheck_raw_entries` 

Edit

SELECT proc.*, raw.* 
FROM deliverycheck_proc_entries `proc`
LEFT OUTER JOIN deliverycheck_raw_entries raw
ON proc.raw_entry_id = raw.id 
WHERE proc.status > '1' 
ORDER BY proc.id ASC
LIMIT 10

Upvotes: 1

banzsh
banzsh

Reputation: 550

Might be a typo but you have joined deliverycheck_proc_entries with itself instead of deliverycheck_raw_entries.

Upvotes: 1

Related Questions