Need help with SQL query - my query at the moment works with two tables I want to add third table, but i have no idea how to do that, I tried many times but it gives error...
I will try to show all my code as more acurate:
SQL QUERY
$sql = "SELECT main.nid, main.title FROM {node} AS main
LEFT JOIN {localizernode} AS lang ON main.nid = lang.nid
WHERE main.type = 'drug' AND main.title LIKE '%s%%' AND lang.language = '%s' AND main.status = 1
ORDER BY main.title ASC";
$result = db_query($sql);
while ($product = db_fetch_object($result)) {
// build up the list
$product_list .= '<li>'.$product->title.'</li>';
}
this QUERY grabs all data from table NODE based on website language where type is drug. And give me a list of all items in side that table, ordering by title
Table "node":
nid | vid | type | title | status
9 | 9 | drug | Title 1 | 1
15 | 15 | drug | Title 2 | 1
Table "content_type_drug" which I want to use/include in QUERY looks like:
vid | nid | value | image_title
9 | 9 | Text value | imagename.jpg
15 | 15 | Text value5 | imagename3.jpg
What I want it to grab from "content_type_drug" the following values: "value", "image_title" and display them in the above list:
$result = db_query($sql);
while ($product = db_fetch_object($result)) {
// build up the list
$product_list .= '<li>'.$product->title.$product->value.$product->image.'</li>';
}
I am looking for help, and not for FULL solution, please give me any ideas.
SELECT main.id AS main_id, lang.id AS lang_id .....