En ARTICLES SEARCH.sql

Материал из MstarProject Manual
Перейти к: навигация, поиск

/* Search of non-original products from the category with the specified text in the name, matching for a given vehicle (TYP_ID) */

/* ART_ID - Product ID */

/* ART_ARTICLE_NR - Article number */

/* STR_DES_TEXT - Category name */

/* ART_COMPLETE_DES_TEXT - Product name */

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 @QUERY = '%brake%disk%'; /* Replace spaces in the searched text with % and add % at the beginning and at the end as well */
SELECT	ART_ID,	ART_ARTICLE_NR,	SUP_BRAND,	DES_TEXTS.TEX_TEXT AS STR_DES_TEXT,	DES_TEXTS2.TEX_TEXT AS ART_COMPLETE_DES_TEXT
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
INNER JOIN SEARCH_TREE ON STR_ID = LGS_STR_ID
INNER JOIN DESIGNATIONS ON DESIGNATIONS.DES_ID = STR_DES_ID AND DESIGNATIONS.DES_LNG_ID = @LNG_ID
INNER JOIN DES_TEXTS ON DES_TEXTS.TEX_ID = DESIGNATIONS.DES_TEX_ID
INNER JOIN ARTICLES ON ART_ID = LA_ART_ID
INNER JOIN SUPPLIERS ON SUP_ID = ART_SUP_ID
INNER JOIN DESIGNATIONS AS DESIGNATIONS2 ON DESIGNATIONS2.DES_ID = ART_COMPLETE_DES_ID
INNER JOIN DES_TEXTS AS DES_TEXTS2 ON DES_TEXTS2.TEX_ID = DESIGNATIONS2.DES_TEX_ID AND DESIGNATIONS2.DES_LNG_ID = @LNG_ID
WHERE	DES_TEXTS.TEX_TEXT LIKE @QUERY;