Trying to populate listview with secondary table data (1 Viewer)

Yesideez

New member
Local time
Today, 01:57
Joined
Jun 28, 2011
Messages
5
I've got this query:

Code:
SELECT worklog.[_propertyid],worklog.id,worklog.address,worklog.postcode,worklog.dateassigned,worklog.workcompleted,worklog.paymentreceived,worklog.added FROM worklog INNER JOIN properties ON worklog.[_propertyid]=properties.id WHERE worklog.[_propertyid]=properties.id ORDER BY worklog.address;
The table "properties" contains a list of properties and the primary key is "id" and I have a second table "worklog" containing a list of all work that has been carried out on the properties. The foreign key in worklog is "_propertyid"

The query pulls data out but instead of only work logs relating to the current property beign viewed I get several.

The properties table has around 6,200 records and worklog has around 12,500 records - I'm getting the recordsI should be getting back but I'm also getting MANY more that shouldn't be.

Please help :)

EDIT: If I change the WHERE part from:
Code:
worklog.[_propertyid]=properties.id
to this:
Code:
worklog.[_propertyid]=6397
it works fine - how do I specify the current property record being viewed? If I miss out the WHERE clause I get back the same results as the query is posted in its entirety above.
 
Last edited:

Users who are viewing this thread

Top Bottom