<?php $featured_query = tep_db_query("(select c.categories_id ,c.categories_image, cd.categories_name, cd.categories_htc_desc_tag from " . TABLE_CATEGORIES . " c, categories_description cd where c.art ='0' and c.categories_id ='" . (int)$parent_category_id . "' and cd.language_id='" . (int)$languages_id . "' and c.categories_id = cd.categories_id LIMIT 1 ) UNION (select c.categories_id,c.categories_image, cd.categories_name, cd.categories_htc_desc_tag from " . TABLE_CATEGORIES . " c, categories_description cd, featured_categories fc where c.art ='0' ".$categories_featured_sql ." ".$manufacturers_featured_sql." and cd.language_id='" . (int)$languages_id . "' and fc.categories_id = c.categories_id and c.categories_id = cd.categories_id ORDER BY RAND() LIMIT 1) "); ?>
Powyzsze zapytanie wybiera dwa rekordy, dwie rozne zasady z tej samej tablicy
Czasem zdazy sie ze druga czresc zapytania wylosuje ten sam rekord co pierwsza. (wtedy go nie pokazuje)
i tu pytanie jak jak tego unikn±æ ?
próbowa³em tak
<?php $featured_query = tep_db_query("(select c.categories_id as first_cid,c.categories_image, cd.categories_name, cd.categories_htc_desc_tag from " . TABLE_CATEGORIES . " c, categories_description cd where c.art ='0' and c.categories_id ='" . (int)$parent_category_id . "' and cd.language_id='" . (int)$languages_id . "' and c.categories_id = cd.categories_id LIMIT 1 ) UNION (select c.categories_id,c.categories_image, cd.categories_name, cd.categories_htc_desc_tag from " . TABLE_CATEGORIES . " c, categories_description cd, featured_categories fc where c.art ='0' and c.categories_id <> first_cid ".$categories_featured_sql ." ".$manufacturers_featured_sql." and cd.language_id='" . (int)$languages_id . "' and fc.categories_id = c.categories_id and c.categories_id = cd.categories_id ORDER BY RAND() LIMIT 1) "); ?>
Co skutkuje
<?php 1054 - Unknown column 'first_cid' in 'where clause' ?>
Jakies propozycje ?
z góry thx