I've got this query:
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:
to this:
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.
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 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
Code:
worklog.[_propertyid]=6397
Last edited: