Hi Luigi, Thanks for your suggestion but that is not what I want.
Doing "AND" is a requirement. Though with "AND", this query is wrong but I hope you get the intention what I want to do. I want to get the part_id which matches all given conditions like this. As I said this can be achieved via joins in traditional dbms with this query select a.part_id from parameter a JOIN parameter b ON (a.part_id=b.part_id) where ( (a.name='p1' and a.value='200') and (b.name='p2' and b.value='blue') ) group by a.part_id Reason for having a parameter class separately is to have a composite index on it for faster querying and second reason is to not lock "Part" while I am modifying its parameters. It will used in highly concurrent environment so I thought it will be better to have two separate classes. On Monday, September 21, 2015 at 3:36:07 PM UTC+9, Luigi Dell'Aquila wrote: > > Hi, > > you are really close to the solution ;-) > Just replace the AND with an OR > > select part_id from Parameter where > > (name='a' and value='10') > > OR > > (name='b' and value='15') > > > Just a couple of hints: > > 1) create a composite index on name and value, it will speed up your > queries a lot > > 2) if 'part' is a complex object, I suggest you to declare part_id as a > link and let it point to the 'part' object, in this case your query will > probably be > > select expand(part_id) from Parameter where > > (name='a' and value='10') > > OR > > (name='b' and value='15') > > > Just a little question: is there a particular reason why you are defining > a Parameter class, instead of having a complex 'part' object with many > (schemaless) parameters? > > Luigi > > > 2015-09-19 11:02 GMT+02:00 mecp <[email protected] <javascript:>>: > >> I am having difficulty in achieving this: >> I have a class *Parameter* with these properties >> >> >> - part_id >> >> - name >> >> - value. >> >> >> One part could have many parameters so part_id and name make a unique >> candidate. >> >> >> I want to query all the parts which match given conditions for name and >> value. >> >> >> For example: >> >> select part_id from Parameter where ( >> >> (name='a' and value='10') >> >> and >> >> (name='b' and value='15') >> >> ) >> >> >> I know this is wrong sql but I wrote it to show my intent. In other DB >> queries it would require JOINS to achieve this, but in orientdb I have no >> clue how I can do this. I am using orientdb as a document db in embedded >> mode. >> >> >> Could someone help on this for orientdb? >> >> -- >> >> --- >> You received this message because you are subscribed to the Google Groups >> "OrientDB" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- --- You received this message because you are subscribed to the Google Groups "OrientDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
