I'm trying to solve the problem of the second day but with no success yet.
My goal is:
For certain taxonomy term ID (for example 1) I need to get at least one imagefield filepath of nodes, which belong to that term id (tid 1)
Below are three queries which give me what I need. All works fine but I know it looks really ugly and, I'm sure, there is a big performance issue.
$childterm = 10; // Taxonomy term ID
$result = db_fetch_array(db_query("SELECT node.vid FROM node JOIN
term_node ON node.vid=term_node.vid WHERE
term_node.tid=$childterm AND
node.type= 'product' LIMIT 0,1"));
$nvid = $result['vid']; // Extracting node VID by term ID that will be used futher
$result = db_fetch_array(db_query("SELECT field_image_cache_fid FROM
content_field_image_cache WHERE
vid = '%d'", $nvid));
$fid = $result['field_image_cache_fid']; // Extracting file ID from array
$result = db_fetch_array(db_query("SELECT filepath FROM files WHERE
files.fid = '%d'", $fid));
$filepath = $result['filepath']; // Finally. Extracting file path from array
Please look at the picture.
How can I improve the query? Can I get filepath value using only ONE sql query?
Thanks in advance.