|
Re: AW: Antwort: SQL->Criteria howto: msg#00125jakarta.turbine.torque.user
Try this one : /* 1) the subSelect */ Criteria subSelectCrit = new Criteria(); subSelectCrit.addAlias("T2", VoravisPeer.TABLE_NAME); // (or simply "VORAVIS") subSelectCrit.addSelectColumn("MAX(T2.SEND_SEQUENZ)"); subSelectCrit.add("T2.AUFT_ID", (Object)"T2.AUFT_ID = T1.AUFT_ID", Criteria.Custom); /* 2) the "top" part of the request */ Criteria topPartCrit = new EnhancedCriteria(); topPartCrit.addAlias("T1", VoravisPeer.TABLE_NAME); /* Might be necessary if you want to restrict to the columns "vavi_id" & "sequenz" topPartCrit.addSelectColumn("T1.VAVI_ID"); topPartCrit.addSelectColumn("T1.SEQUENZ") */ /* addIn : see (3) */ topPartCrit.addIn("T1.SEND_SEQUENZ", subSelectCrit); topPartCrit.add("T1.AUFT_ID", new Integer(#your_value#))); 3) Requirement : A method "Criteria.addIn(String column, String Criteria)", but obviously you already have it. There might be some flaws concerning the number of columns you want to get (all or only vavi_id & sequenz), and the fact that you might want the Peer Objects associated with the results (that is using VoravisPeer.doSelect(topPartCrit)) or just the records (VoravisPeer.doSelectVillageRecords(topParCrit)). But the subquery problem should be ok. Regards. Sperlich, Tino a écrit : Hi all, |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Foreign key integrity constraints and Transactions: 00125, John Harris |
|---|---|
| Next by Date: | RE: Antwort: SQL->Criteria howto: 00125, Thomas Fischer |
| Previous by Thread: | AW: Antwort: SQL->Criteria howtoi: 00125, Sperlich, Tino |
| Next by Thread: | Re: AW: Antwort: SQL->Criteria howto: 00125, Richard Bayet |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |