En SEARCH TREE.sql
Материал из MstarProject Manual
Версия от 09:43, 15 мая 2013; Mstar (обсуждение | вклад)
/* Construction of a tree of product categories for a given type of vehicle (TYP_ID) */
SET @TYP_ID = 3822; /* ALFA ROMEO 145 (930) 1.4 i.e. [1994/07-1996/12] */ SET @LNG_ID = 16; /* 1 - German; 16 - Russian */ SET @STR_ID = NULL; /* Tree root */
/* By consecutive setting of the following STR_ID values you can get 4 more tree levels: */
/* SET @STR_ID = 10001; /* Passenger cars */
/* SET @STR_ID = 10102; /* Engine */
/* SET @STR_ID = 10615; /* Crank gear */
/* SET @STR_ID = 10620; /* Piston */
/* Display of a list of subcategories for the selected category with @STR_ID number,*/
/* containing products for a given type of vehicle (TYP_ID) */
/* STR_ID - Category number */
/* STR_DES_TEXT - Category name */
/* DESCENDANTS - Whether the given category has subcategories: 1 - Has, 0 - Has not */
SELECT STR_ID, TEX_TEXT AS STR_DES_TEXT, IF( EXISTS( SELECT * FROM SEARCH_TREE AS SEARCH_TREE2 WHERE SEARCH_TREE2.STR_ID_PARENT <=> SEARCH_TREE.STR_ID LIMIT 1), 1, 0) AS DESCENDANTS FROM SEARCH_TREE INNER JOIN DESIGNATIONS ON DES_ID = STR_DES_ID INNER JOIN DES_TEXTS ON TEX_ID = DES_TEX_ID WHERE STR_ID_PARENT <=> @STR_ID AND DES_LNG_ID = @LNG_ID AND EXISTS ( SELECT * FROM LINK_GA_STR INNER JOIN LINK_LA_TYP ON LAT_TYP_ID = @TYP_ID AND LAT_GA_ID = LGS_GA_ID INNER JOIN LINK_ART ON LA_ID = LAT_LA_ID WHERE LGS_STR_ID = STR_ID LIMIT 1 );
- Back to index page: Tecdoc_queries_and_structure_manual_-_version_2
- Prices and packages for Irbis software based on tecdoc from Mstarproject company: http://www.mstarproject.com/en/?action=tecdoc_mysql_site