Author Topic

Nathan Kelly

Friday 23 February 2007 4:11:57 pm

Comment47821

Thanks for the detailed breakdown Claudia, I realized late last night that I didn't really explain my first example very well.

What I should have used as the example is more like the following:

SELECT DISTINCT myObjectID
FROM myTable

Where myObjectID's in myTable are not unique values. Basically there are approximately 420 rows in my table with only 24 out of a possible 200 unique myObjectID's in use. So my table looks something like:

myObjectID	myObjectName

12		whatever
12		another name
23		name on an object
198		example
12		test name

and so on...

What I needed to do was fetch only unique myObjectID's, so that the query should only return 24 results rather than 420. But this is not what I need to do now so this example is no longer valid.

Now however, as in my last example things have become more complex, in tableOne there are 200 rows and 2 columns, I need to collect myObjectID and myObjectName but only where myObjectID exists in tableTwo which has 420 rows. This should return the desired 24 unique results and ignore the other 396 redundant rows.

SELECT DISTINCT tableOne.*
FROM tableOne, tableTwo
WHERE tableOne.myObjectID
IN (tableTwo.myObjectID)
ORDER BY myObjectName ASC

It took me all of 1 minute to write my query and get the expected result, and in a normal PHP app I'd have no trouble doing so, but translating this into something that the ezpersistantobject can work with is proving very difficult. It honestly doesn't make sense to me why creating a simple query in Exponential should be such a convoluted task, why can't I just write my query and get the expected result?

I really appreciate the assistance, I would like to become more familiar with the core functionality of ez but it's going to take time.

Cheers.

Pardon me while I burst into flames...