[TYPO3-dev] DBAL: SELECT DISTINCT

Franz Holzinger franz at fholzinger.com
Thu Jun 8 18:49:52 CEST 2006


Hello,

I need to use a 'SELECT DISTINCT' query, but there seems to be only the
normal sql_query($query) within DBAL. The SELECTquery and
exec_SELECTquery functions do not support this.


E.g. I want to use this query:

SELECT DISTINCT	
	products.uid uid,tt_products_language.pid pid,products.category
category,products.price price,products.price2 price2,products.tax
tax,products.inStock inStock,tt_products_language.title
title,products.image image,products.size size
FROM 	
	tt_products_cat_language tt_products_cat_language, tt_products_language
tt_products_language,tt_products products LEFT OUTER JOIN
tt_products_cat tt_products_cat ON tt_products_cat.uid=products.category
WHERE 	
	products.pid IN (119) AND products.uid = tt_products_language.prod_uid
AND 1=1 AND (products.inStock <> 0) AND
tt_products_language.sys_language_uid=2 AND tt_products_language.deleted=0


Without the DISTINCT I get 5 identical rows where only 1 should be there
because I have only one product with language 2.

Or do you know a way how to change this SELECT statement that it will
take the categories from tt_products and the text fields from
tt_products_language where the row will be returned once?

Should 'DISTINCT' be supported by the DBAL functions?

Greets,

Franz





More information about the TYPO3-dev mailing list