Hallo ich stehe vor folgenden Problem. Es geht um eine Suchfunktion ich habe nämlich einen Baum und ich möchte nur innerhalb der Untergeordneten Einträge suchen. Könnt ihr mir sagen wie ich dies lösen kann. Hier die Datenbankstruktur:
Tabelle catalog_tree:
parent - bigint(15) unsigned -> Parent
id - bigint(15) unsigned -> ID
field_value - int(10) -> ID der verknüpften Tabelle
level - char(10) -> Typ
Tabelle spare_parts
pos_id - bigint(20) unsigned
part_id - bigint(20) unsigned
machine - bigint(20) unsigned
part_nr
position
...
Hier meine bisherige SQL:
"SELECT NULL, NULL, s.pos_id, s.part_id, s.position, s.part_nr, s.amount, s.q_unit, s.has_child, s.is_draw, s.p_memo, s.c_memo, s.price, s.currency
FROM spare_parts AS s
LEFT JOIN catalog_tree AS t
ON (s.pos_id = t.field_value)
LEFT JOIN element_desc AS d
ON (s.part_id = d.id_value AND d.tab_name = 'TbSpareParts' AND d.language = '$l')
WHERE s.machine = $tree_mach_value AND t.parent = $treee_id $add_condition ORDER BY s.has_child DESC, s.ord_num, s.position");
Danke für eure Hilfe.
Tabelle catalog_tree:
parent - bigint(15) unsigned -> Parent
id - bigint(15) unsigned -> ID
field_value - int(10) -> ID der verknüpften Tabelle
level - char(10) -> Typ
Tabelle spare_parts
pos_id - bigint(20) unsigned
part_id - bigint(20) unsigned
machine - bigint(20) unsigned
part_nr
position
...
Hier meine bisherige SQL:
"SELECT NULL, NULL, s.pos_id, s.part_id, s.position, s.part_nr, s.amount, s.q_unit, s.has_child, s.is_draw, s.p_memo, s.c_memo, s.price, s.currency
FROM spare_parts AS s
LEFT JOIN catalog_tree AS t
ON (s.pos_id = t.field_value)
LEFT JOIN element_desc AS d
ON (s.part_id = d.id_value AND d.tab_name = 'TbSpareParts' AND d.language = '$l')
WHERE s.machine = $tree_mach_value AND t.parent = $treee_id $add_condition ORDER BY s.has_child DESC, s.ord_num, s.position");
Danke für eure Hilfe.
Kommentar