Re: Simple problem with a nested entity and it's SQL

2009-10-28 Thread Jonathan Hendler
THanks - That's a good question. I thought of using one single SQL statement - but the nested entity's query is actually quite complex (unlike the example). So it'd be possible, but more readable as a separate query. Further, MySQL has some limitations also about temporary tables and seems l

RE: Simple problem with a nested entity and it's SQL

2009-10-28 Thread Fuad Efendi
Why can't we use single entity with single SELECT ... LEFT OUTER JOIN ...? > -Original Message- > From: Jonathan Hendler [mailto:jonathan.hend...@gmail.com] > Sent: October-28-09 1:33 PM > To: solr-user@lucene.apache.org > Subject: Simple problem with a nested entity and it's SQL > > I

Re: Simple problem with a nested entity and it's SQL

2009-10-28 Thread Avlesh Singh
Awesome! Its not a bad solution at all. Cheers Avlesh On Wed, Oct 28, 2009 at 11:33 PM, Jonathan Hendler < jonathan.hend...@gmail.com> wrote: > Thanks - that solution still causes an error. > > But it helped me think of an SQL solution like so : > CONVERT ( '${table1.somethin_like_a_foreign_key}

Re: Simple problem with a nested entity and it's SQL

2009-10-28 Thread Jonathan Hendler
Thanks - that solution still causes an error. But it helped me think of an SQL solution like so : CONVERT ( '${table1.somethin_like_a_foreign_key}' , UNSIGNED INTEGER ) Convert the integer or NULL to a string, then back again. (ugly but it works) On Oct 28, 2009, at 1:48 PM, Avlesh Singh

Re: Simple problem with a nested entity and it's SQL

2009-10-28 Thread Avlesh Singh
Assuming this to be MySQL, will this work - SELECT * FROM table2 WHERE id = IF(ISNULL(${table1.somethin_like_a_foreign_key}), 0, ${table1.somethin_like_a_foreign_key}); Cheers Avlesh On Wed, Oct 28, 2009 at 11:12 PM, Jonathan Hendler < jonathan.hend...@gmail.com> wrote: > No - the SQL will fail

Re: Simple problem with a nested entity and it's SQL

2009-10-28 Thread Jonathan Hendler
No - the SQL will fail to validate because at runtime it will look like SELECT * FROM table2 WHERE IS NOT NULL table1.somethin_like_a_foreign_key AND table1.somethin_like_a_foreign_key > 0 AND id = Note the "id = " On Oct 28, 2009, at 1:38 PM, Avlesh Singh wrote: Shouldn't this work too?

Re: Simple problem with a nested entity and it's SQL

2009-10-28 Thread Avlesh Singh
Shouldn't this work too? SELECT * FROM table2 WHERE IS NOT NULL ${table1.somethin_like_a_foreign_key} AND ${table1.somethin_like_a_foreign_key} > 0 AND id = ${table1.somethin_like_a_foreign_key} Cheers Avlesh On Wed, Oct 28, 2009 at 11:03 PM, Jonathan Hendler < jonathan.hend...@gmail.com> wrote: