1

I'm not used to working with PostgreSQL, but am using Zend_Db_Select to create my queries. What does the error below mean?

SQL error:
ERROR:  schema "il" does not exist

In statement:
SELECT il.count(*) AS "count" FROM "image_lite" AS "il" 
INNER JOIN "exif_parse" AS "ex" ON il.image_id = ex.image_id 
WHERE (ex.cam_make = 'apple')

3 Answers 3

6

It's parsing il.count(*) as a call to a function "count" in the schema "il". Probably what you want is the expression:

count(il.*)
Sign up to request clarification or add additional context in comments.

Comments

5

You can think of schema in PostgreSQL as you would a database in MySQL. Also try removing the double quotes around everything because that's just plain strange and might be causing the problem.

Oh I see il.count(*) make no sense at all.

Just do this instead:

select count(*) cnt       
  from image_lite il 
  join exif_parse ex on il.image_id = ex.image_id 
 where ex.cam_make = 'apple'

3 Comments

+1 for removing the double-quotes. That irritates me just as much when people backtick the heck out of everything in a MySQL statement... probably where the bad habit came from!
The quotes are automatically inserted by the Zend_Db_Select
quotes can lead to unexpected behaviours in postgresql if identifiers are not lowercase (not your case but anyway). Khorkrak gives the correct sane syntax
1

Postgres is interpreting the "il" in "il.count(*)" as a schema name. You can simply omit it and ask for count(*), or if you want to get specific, count(il.*)

If you're coming from MySQL, schemas are what the rest of the world calls what MySQL calls a database.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.