We managed awhile back to cobble some really complex (to us) database queries that pull some dynamic meta_values in with the general Post info in WordPress so that the result was a nice, full list of key=>value pairs. It's worked great for years but now we've switched to MariaDB and it's no longer ordering properly and I'm not sure why. See below for one of the big, long examples or screenshot at https://screencast.com/t/mFILYpWf for a bit more formatting.
Any ideas on how I can get it to order by menu_order first, last_name then first_name?
Thanks as always!!
SELECT *
FROM
(
SELECT wp_posts.ID, wp_posts.menu_order, wp_posts.post_title,
wp_posts.post_name,
MAX(CASE WHEN wp_postmeta.meta_key = 'lawyer_job_title'
THEN wp_postmeta.meta_value END ) AS 'job_title',
MAX(CASE WHEN wp_postmeta.meta_key = 'lawyer_prefix'
THEN wp_postmeta.meta_value END ) AS 'prefix',
MAX(CASE WHEN wp_postmeta.meta_key = 'lawyer_first_name'
THEN wp_postmeta.meta_value END ) AS 'first_name',
MAX(CASE WHEN wp_postmeta.meta_key = 'lawyer_middle_name'
THEN wp_postmeta.meta_value END ) AS 'middle_name',
MAX(CASE WHEN wp_postmeta.meta_key = 'lawyer_last_name'
THEN wp_postmeta.meta_value END ) AS 'last_name',
MAX(CASE WHEN wp_postmeta.meta_key = 'lawyer_suffix'
THEN wp_postmeta.meta_value END ) AS 'suffix',
MAX(CASE WHEN wp_postmeta.meta_key = 'lawyer_languages'
THEN wp_postmeta.meta_value END ) AS 'languages',
MAX(CASE WHEN wp_postmeta.meta_key = 'lawyer_email'
THEN wp_postmeta.meta_value END ) AS 'email',
MAX(CASE WHEN wp_postmeta.meta_key = 'lawyer_phone'
THEN wp_postmeta.meta_value END ) AS 'phone',
MAX( CASE WHEN wp_postmeta.meta_key = 'lawyer_offices' THEN wp_postmeta.meta_value END ) AS 'offices',MAX( CASE WHEN wp_postmeta.meta_key = 'lawyer_linkedin' THEN wp_postmeta.meta_value END ) AS 'linkedin',MAX( CASE WHEN wp_postmeta.meta_key = 'lawyer_biography' THEN wp_postmeta.meta_value END ) AS 'biography',MAX( CASE WHEN wp_postmeta.meta_key = 'lawyer_bio_field_credentials' THEN wp_postmeta.meta_value END ) AS 'bio_field_credentials',MAX( CASE WHEN wp_postmeta.meta_key = 'lawyer_bio_field_affiliations' THEN wp_postmeta.meta_value END ) AS 'bio_field_affiliations',MAX( CASE WHEN wp_postmeta.meta_key = 'lawyer_bio_field_accolades' THEN wp_postmeta.meta_value END ) AS 'bio_field_accolades',MAX( CASE WHEN wp_postmeta.meta_key = 'lawyer_bio_field_notable_decisions' THEN wp_postmeta.meta_value END ) AS 'bio_field_notable_decisions',MAX( CASE WHEN wp_postmeta.meta_key = 'lawyer_bio_field_education_admissions' THEN wp_postmeta.meta_value END ) AS 'bio_field_education_admissions',MAX( CASE WHEN wp_postmeta.meta_key = 'lawyer_bio_image' THEN wp_postmeta.meta_value END ) AS 'bio_image',MAX( CASE WHEN wp_postmeta.meta_key = 'lawyer_directory_image' THEN wp_postmeta.meta_value END ) AS 'directory_image',MAX( CASE WHEN wp_postmeta.meta_key = 'lawyer_pdf_image' THEN wp_postmeta.meta_value END ) AS 'pdf_image',MAX( CASE WHEN wp_postmeta.meta_key = 'lawyer_practices' THEN wp_postmeta.meta_value END ) AS 'practices',MAX( CASE WHEN wp_postmeta.meta_key = 'lawyer_related_posts' THEN wp_postmeta.meta_value END ) AS 'related_posts',MAX( CASE WHEN wp_postmeta.meta_key = 'lawyer_other_news' THEN wp_postmeta.meta_value END ) AS 'other_news',MAX( CASE WHEN wp_postmeta.meta_key = 'lawyer_related_staff' THEN wp_postmeta.meta_value END ) AS 'related_staff', concat( 'http://wiedner.localhost/lawyer/', wp_posts.post_name, '/' ) AS 'permalink' FROM wp_posts LEFT JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE wp_posts.post_status = 'publish' AND wp_posts.post_type = 'lawyer'
GROUP BY wp_posts.ID
ORDER BY menu_order asc, last_name asc, first_name asc
) AS t
WHERE 1=1
Simplify it by getting rid of the outer SELECT!
The reason is that a 'derived' table (your subquery) has no order. (This has long been in Standard SQL, but only recently have MariaDB, and later MySQL, taken advantage of it.) That is, the execution is justified to get rid of your carefully written ORDER BY.
But, by stopping with the inner query; it is obligated to honor the ORDER BY.
MariaDB may have a different mode set. Try this, and see here:
SET GLOBAL sql_mode=(SELECT REPLACE(##sql_mode,'ONLY_FULL_GROUP_BY',));
Also this may be a duplicate, see this related question.
Related
I have been trying to extract useful product feeds but there is still one attribute missing in the feed "image link"
Can anyone suggest me a tweak in the following query to make it perfect?
SELECT
`product`.`ID` AS `product_id`,
`product`.`post_title` AS `Title`,
`product`.`post_title` AS `Description`,
`product_price`.`meta_value` AS `Price`,
'no' AS `Identifier_exists`,
'Free' AS `Shipping`,
'in stock' AS `Availability`,
'new' AS `Condition`,
`product`.`guid` AS `Link`
FROM
(
(
(
`wp_posts` `product`
LEFT JOIN `wp_postmeta` `product_sku`
ON
(
(
`product`.`ID` = `product_sku`.`post_id`
)
)
)
LEFT JOIN `wp_postmeta` `product_price`
ON
(
(
`product`.`ID` = `product_price`.`post_id`
)
)
)
LEFT JOIN `wp_postmeta` `product_weight`
ON
(
(
`product`.`ID` = `product_weight`.`post_id`
)
)
)
WHERE
(
(
(`product`.`post_type` = 'product')
OR(`product`.`post_type` = 'product_variation')
) AND(`product_sku`.`meta_key` = '_sku') AND(
`product_price`.`meta_key` = '_price'
) AND(
`product_weight`.`meta_key` = '_weight'
)
)
ORDER BY
`product_id`
I'm hoping somebody can help me, I've got a woocommerce install that 504 errors when adding a product with six attributes to the cart. There is one 'catchall' variation set up for the product. I have disabled all plugins and reverted to the storefront theme and still experience the same issue, it appears to be directly related to a very slow SQL query that is being run.
The query appears to be selecting the post ID where the meta values for the attribute match the selected attributes which in this case is suboptimal as there are 70k entries in the post_meta table and hundreds in the post table. This query does not complete in a reasonable timeframe and is called more than once so kills off the SQL server. Personally I was able to rewrite the query to be much faster in mysql workbench but I can't figure out where it's being generated. The query is as follows:
SELECT wp_posts.ID FROM wp_posts LEFT JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) LEFT JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id AND mt1.meta_key = 'attribute_pa_workbee-size-drive' ) LEFT JOIN wp_postmeta AS mt2 ON ( wp_posts.ID = mt2.post_id ) LEFT JOIN wp_postmeta AS mt3 ON (wp_posts.ID = mt3.post_id AND mt3.meta_key = 'attribute_pa_extrusion-colour' ) LEFT JOIN wp_postmeta AS mt4 ON ( wp_posts.ID = mt4.post_id ) LEFT JOIN wp_postmeta AS mt5 ON (wp_posts.ID = mt5.post_id AND mt5.meta_key = 'attribute_pa_router' ) LEFT JOIN wp_postmeta AS mt6 ON ( wp_posts.ID = mt6.post_id ) LEFT JOIN wp_postmeta AS mt7 ON (wp_posts.ID = mt7.post_id AND mt7.meta_key = 'attribute_pa_dust-shoe' ) LEFT JOIN wp_postmeta AS mt8 ON ( wp_posts.ID = mt8.post_id ) LEFT JOIN wp_postmeta AS mt9 ON (wp_posts.ID = mt9.post_id AND mt9.meta_key = 'attribute_pa_cam-software' ) LEFT JOIN wp_postmeta AS mt10 ON ( wp_posts.ID = mt10.post_id ) LEFT JOIN wp_postmeta AS mt11 ON (wp_posts.ID = mt11.post_id AND mt11.meta_key = 'attribute_pa_connectivity' ) WHERE 1=1 AND wp_posts.post_parent = 2603 AND (
(
( wp_postmeta.meta_key = 'attribute_pa_workbee-size-drive' AND wp_postmeta.meta_value IN ('','') )
OR
mt1.post_id IS NULL
)
AND
(
( mt2.meta_key = 'attribute_pa_extrusion-colour' AND mt2.meta_value IN ('','') )
OR
mt3.post_id IS NULL
)
AND
(
( mt4.meta_key = 'attribute_pa_router' AND mt4.meta_value IN ('','') )
OR
mt5.post_id IS NULL
)
AND
(
( mt6.meta_key = 'attribute_pa_dust-shoe' AND mt6.meta_value IN ('','') )
OR
mt7.post_id IS NULL
)
AND
(
( mt8.meta_key = 'attribute_pa_cam-software' AND mt8.meta_value IN ('','') )
OR
mt9.post_id IS NULL
)
AND
(
( mt10.meta_key = 'attribute_pa_connectivity' AND mt10.meta_value IN ('','') )
OR
mt11.post_id IS NULL
)
) AND wp_posts.post_type = 'product_variation' AND ((wp_posts.post_status = 'publish')) GROUP BY wp_posts.ID ORDER BY wp_posts.menu_order ASC LIMIT 0, 1
I have this query in my application
SELECT
/*+ parallel (4) */
a.orgkey AS cifid,
a.strfield19 AS old_cif_id,
a.cust_first_name,
a.cust_middle_name,
a.cust_last_name,
a.primary_sol_id AS sol_id,
(
SELECT lang.localetext
FROM crmuser.categories cat,
crmuser.category_lang lang
WHERE cat.categoryid=lang.categoryid
AND cat.categorytype= 'PERSONSALUTATION'
AND cat.bank_id =
(
SELECT bank_id
FROM migadm.migr_det)
AND lang.bank_id =
(
SELECT bank_id
FROM migadm.migr_det)
AND cat.value= a.salutation) AS saluatation,
a.segmentation_class AS segmentation_class,
CASE
WHEN corp_id IS NULL THEN
(
SELECT lang.localetext
FROM crmuser.categories cat,
crmuser.category_lang lang
WHERE cat.categoryid=lang.categoryid
AND cat.categorytype= 'SEGMENTATION_CLASS'
AND cat.bank_id =
(
SELECT bank_id
FROM migadm.migr_det)
AND lang.bank_id =
(
SELECT bank_id
FROM migadm.migr_det)
AND cat.value= a.segmentation_class)
ELSE
(
SELECT lang.localetext
FROM crmuser.categories cat,
crmuser.category_lang lang
WHERE cat.categoryid=lang.categoryid
AND cat.categorytype= 'CORP_SEGMENTATION_CLASS'
AND cat.bank_id =
(
SELECT bank_id
FROM migadm.migr_det)
AND lang.bank_id =
(
SELECT bank_id
FROM migadm.migr_det)
AND cat.value= a.segmentation_class)
END AS segmentation_desc,
a.subsegment AS subsegment,
CASE
WHEN corp_id IS NULL THEN
(
SELECT lang.localetext
FROM crmuser.categories cat,
crmuser.category_lang lang
WHERE cat.categoryid=lang.categoryid
AND cat.categorytype= 'SUB_SEGMENT'
AND cat.bank_id =
(
SELECT bank_id
FROM migadm.migr_det)
AND lang.bank_id =
(
SELECT bank_id
FROM migadm.migr_det)
AND cat.value= a.subsegment)
ELSE
(
SELECT lang.localetext
FROM crmuser.categories cat,
crmuser.category_lang lang
WHERE cat.categoryid=lang.categoryid
AND cat.categorytype= 'CORP_SUB_SEGMENT'
AND cat.bank_id =
(
SELECT bank_id
FROM migadm.migr_det)
AND lang.bank_id =
(
SELECT bank_id
FROM migadm.migr_det)
AND cat.value= a.subsegment)
END AS subsegment_desc,
CASE
WHEN a.corp_id IS NULL THEN a.strfield10
ELSE c.struserfield4
END AS reserve_bank_code,
CASE
WHEN a.corp_id IS NULL THEN a.strfield11
ELSE c.struserfield5
END AS form50_code,
a.sector AS pri_sic_code,
a.subsector AS sec_sic_code,
CASE
WHEN a.corp_id IS NULL THEN a.struserfield3
ELSE c.struserfield3
END AS kyc_indicator,
a.defaultaddresstype AS defaultaddresstype,
b.address_line1,
b.address_line2,
b.address_line3,
CASE
WHEN a.corp_id IS NULL THEN
(
SELECT (ad.address_line1
||' '
||ad.address_line2
||' '
||ad.address_line3)
FROM crmuser.address ad
WHERE a.orgkey=ad.orgkey
AND ad. preferredaddress='Y'
AND
(
SELECT migration_date
FROM migadm.migr_det) BETWEEN ad.start_date AND ad.end_date)
ELSE
(
SELECT (ad.address_line1
||' '
||ad.address_line2
||' '
||ad.address_line3)
FROM crmuser.address ad
WHERE a.orgkey=ad.orgkey
AND ad.preferredaddress='Y' and
(
SELECT migration_date
FROM migadm.migr_det) BETWEEN ad.start_date AND ad.end_date)
END AS postal_adress,
b.zip AS postal_code,
a.gender AS gender,
a.cust_dob AS date_of_birth,
(
SELECT p.email
FROM crmuser.phoneemail p
WHERE p.orgkey = a.orgkey
AND p.preferredflag='Y'
AND phoneoremail='EMAIL'
AND ROWNUM =1) email_id,
(
SELECT p.phonenocountrycode
FROM crmuser.phoneemail p
WHERE p.orgkey = a.orgkey
AND p.preferredflag='Y'
AND phoneoremail='PHONE'
AND ROWNUM =1) AS phone_cntry_code,
(
SELECT p.phonenocitycode
FROM crmuser.phoneemail p
WHERE p.orgkey = a.orgkey
AND p.preferredflag='Y'
AND phoneoremail='PHONE'
AND ROWNUM =1) AS phone_city_code,
(
SELECT '+'
|| p.phonenocountrycode
|| '('
|| p.phonenocitycode
|| ')'
|| p.phonenolocalcode
FROM crmuser.phoneemail p
WHERE p.orgkey = a.orgkey
AND p.preferredflag = 'Y'
AND phoneoremail='PHONE') phone_no,
--CASE WHEN (SELECT COUNT(1) FROM crmuser.miscellaneousinfo m WHERE a.orgkey=m.orgkey and type = 'CURRENCY') = 1 THEN (SELECT strtext10 FROM crmuser.miscellaneousinfo m WHERE a.orgkey=m.orgkey and type = 'CURRENCY')
-- WHEN (SELECT COUNT(1) FROM crmuser.corpmiscellaneousinfo m WHERE a.orgkey=m.orgkey and type = 'CURRENCY') = 1 THEN (SELECT str1 FROM crmuser.corpmiscellaneousinfo m WHERE a.orgkey=m.orgkey and type = 'CURRENCY')
-- ELSE
migadm.getcurrencies(a.orgkey)
--END
AS crncy_code,
CASE
WHEN a.corp_id IS NULL THEN a.struserfield15
ELSE c.struserfield6
END AS wht_indicator,
a.cust_swift_code_desc AS cust_swift_code_desc,
customernreflg AS customernreflg,
(
SELECT employerid
FROM crmuser.miscellaneousinfo s
WHERE s.orgkey = a.orgkey
AND TYPE ='CURRENT_EMPLOYMENT') AS group_number,
(
SELECT strtext4
FROM crmuser.miscellaneousinfo s
WHERE s.orgkey = a.orgkey
AND TYPE ='CURRENT_EMPLOYMENT' ) AS employment_details,
--(select EMPLOYERSNAME from crmuser.DEMOGRAPHIC s where s.orgkey = a.orgkey ) AS employment_details,
(
SELECT employeeid
FROM crmuser.miscellaneousinfo s
WHERE s.orgkey = a.orgkey
AND TYPE ='CURRENT_EMPLOYMENT' ) AS employeeid,
--(select EMPLOYERID from crmuser.MISCELLANEOUSINFO s where s.orgkey = a.orgkey ) AS employerid,
a.manager AS manager,
CASE
WHEN a.corp_id IS NULL THEN d.annual_salary_income
ELSE c.average_annualincome
END AS annual_income,
c.registration_number
FROM crmuser.corporate c
right join crmuser.address b
ON b.orgkey=c.corp_key
right join crmuser.accounts a
ON b.orgkey=a.orgkey
left join crmuser.demographic d
ON a.orgkey=d.orgkey
WHERE a.bank_id =
(
SELECT bank_id
FROM migadm.migr_det)
AND a.entity_cre_flag = 'Y'
AND b.preferredaddress = 'Y'
It takes more than 20 minutes to give results. Can someone please help me in tuning this query. I don't have any idea about sql.
I can give the explain plan needed but I don't know how to copy here the 111 rows from plan table
How do I write this "WHERE" condition in a way which is compatible with Doctrine?
( ( `translations_es_google`.`translation_date` < `translations_masters`.`translation_date` ) OR ( `translations_es_google`.`translation_date` is null ) )
What I have tried (unsuccessfully) are:
$query1
->andWhere('((t.translationDate < m.translationDate) OR (t.translationDate is NULL))');
$query1
->andWhere('(t.translationDate < m.translationDate) OR (t.translationDate is NULL)');
Table alias for the Doctrine query are
t represents the table translations_es_google
m represents the table translations_masters
When I remove this "andWhere" condition the rest of the QueryBuilder query executes as expected.
The query I am trying to execute is
SELECT
`translations_masters`.`translation_key` , `translations_masters`.`text_domain` , `translations_masters`.`translation_date`
FROM
`translations_masters`
LEFT JOIN
`translations_es_google` ON ( ( `translations_masters`.`text_domain` = `translations_es_google`.`text_domain` ) AND ( `translations_masters`.`translation_key` =`translations_es_google`.`translation_key` ) )
WHERE
`translations_masters`.`language_iso` NOT LIKE 'es-Google' AND ( ( `translations_es_google`.`translation_date` < `translations_masters`.`translation_date` ) OR ( `translations_es_google`.`translation_date` is null ) )
GROUP BY
`translations_masters`.`translation_key` , `translations_masters`.`text_domain`
ORDER BY
`translations_masters`.`translation_date` ASC
As requested the QueryBuilder version of this query is:
$query1 = $this->entityManager
->createQueryBuilder()
->select('m.textDomain , m.translationKey , m.translationDate , m.translationDate AS translationMasterDate , t.translationDate')
->from(
'AMDatabase\Entity\TheVerse\Translations' . $explode1 . $explode2,
't'
)
->leftJoin(
'AMDatabase\Entity\TheVerse\TranslationsMasters',
'm',
Join::WITH,
'(m.textDomain = t.textDomain) AND (m.translationKey = t.translationKey)'
)
->groupBy('m.textDomain , m.translationKey')
->orderBy(
'm.translationDate',
'ASC'
)
->setMaxResults('1');
$query1
->andWhere(
$query1->expr()
->notLike(
'm.languageIso',
':languageIso'
)
)
->setParameter(
'languageIso',
$value
);
$query1->andWhere(
$query1->expr()->orX(
't.translationDate < m.translationDate',
't.translationDate IS NULL'
)
);
$result1 = $query1->getQuery()
->getArrayResult();
The output of $query1->getQuery()->getSQL() is
SELECT
t0_.text_domain AS text_domain_0, t0_.translation_key AS translation_key_1, t0_.translation_date AS translation_date_2, t0_.translation_date AS translation_date_3, t1_.translation_date AS translation_date_4
FROM
thev1010_theverseoftheday.translations_es_google t1_
LEFT JOIN
thev1010_theverseoftheday.translations_masters t0_ ON ((t0_.text_domain = t1_.text_domain) AND (t0_.translation_key = t1_.translation_key))
WHERE
t0_.language_iso NOT LIKE ? AND (t1_.translation_date < t0_.translation_date OR t1_.translation_date IS NULL)
GROUP BY
t0_.text_domain, t0_.translation_key
ORDER BY
t0_.translation_date ASC
LIMIT 1
The ? value is 'es-Google'
The output of $query1->getQuery()->getDQL(); is
SELECT
m.textDomain , m.translationKey , m.translationDate , m.translationDate AS translationMasterDate , t.translationDate
FROM
AMDatabase\Entity\TheVerse\TranslationsEsGoogle t
LEFT JOIN
AMDatabase\Entity\TheVerse\TranslationsMasters m WITH (m.textDomain = t.textDomain) AND (m.translationKey = t.translationKey)
WHERE
m.languageIso NOT LIKE :languageIso AND (t.translationDate < m.translationDate OR t.translationDate IS NULL)
GROUP BY
m.textDomain , m.translationKey
ORDER BY
m.translationDate ASC
The ? value is 'es-Google'
How about orX expression?
You can try it this way:
$query1->andWhere(
$query1->expr()->orxX(
't.translationDate < m.translationDate',
't.translationDate IS NULL'
)
);
orX gives you the ability to add multiple conditions, separated by comma.
You can also separate your orX condition to its own variable and pass everything added to it to andWhere condition.
i have this ( huge ) sql query to convert into doctrine2 .
i already succeeded with createNativeQuery() but sometimes results don't match original one ( from mysql )
here is the query :
SELECT e1_.etapes AS etapes3, e1_.position AS position4, c0_.exercicesData_id AS Exercice_id, exo.titre as Exo, age.bornInf as ageInf, age.bornSup as ageSup, imc.bornInf as imcInf, imc.bornSup as imcSup, sexe.bornInf as sexeInf, sexe.bornSup as sexeSup
FROM ContrainteData c0_
LEFT JOIN ExerciceData e1_ ON c0_.exercicesData_id = e1_.id
LEFT JOIN Exercice exo ON e1_.exercice_id = exo.id
LEFT JOIN contraintedata_entrydata c3_ ON c0_.id = c3_.contraintedata_id
INNER JOIN (SELECT * FROM `entrydata` GROUP BY type_id, bornInf, bornSup) AS age ON age.type_id = 1
INNER JOIN (SELECT * FROM `entrydata` GROUP BY type_id, bornInf, bornSup) AS imc ON imc.type_id = 4
INNER JOIN (SELECT * FROM `entrydata` GROUP BY type_id, bornInf, bornSup) AS sexe ON sexe.type_id = 5
WHERE
( age.bornSup >= 30 and age.bornInf <= 30 ) and
( imc.bornSup >= 20 and imc.bornInf <= 20 ) and
( sexe.bornSup >= 1 and sexe.bornInf <= 1 ) and
e1_.entrainement_id = 6
GROUP BY etapes3, position4
ORDER BY etapes3 ASC, position4 ASC
with the queryBuilder , i have done the following :
$qb1 = $this->createQueryBuilder('c');
$qb2 = $this->createQueryBuilder('t');
$qb2->select( 't' )
->from ( 'bonk\AppBundle\Entity\EntryData', 'en' )
->groupBy( 'en.type')
->addGroupBy( 'en.bornInf' )
->addGroupBy( 'en.bornSup' );
$qb1->select( 'c' )
->leftJoin( 'c.exercicesData', 'e' )
->leftJoin( 'e.exercice' , 'ex' )
->join ( $qb2->getDql(), 'age', 'with', 'age.type = 1' )
->join ( $qb2->getQuery()->getDql(), 'imc', 'with', 'imc.type = 4' )
->join ( $qb2->getQuery()->getDql(), 'sexe', 'with', 'sexe.type = 5')
->where ( 'age.bornSup >= 30 and age.bornInf <= 30' )
->andWhere( 'imc.bornSup >= 20 and imc.bornInf <= 20' )
->andWhere( 'sexe.bornSup >= 1 and sexe.bornInf <= 1' )
->andWhere( 'e.entrainement = 6' )
->groupBy ( 'e.etapes', 'ASC' )
->addGroupBy( 'e.position', 'ASC' );
return $qb1->getQuery()->getArrayResult();
i have the following error :
"[Semantical Error] line 0, col 116 near 'SELECT t FROM': Error: Class 'SELECT' is not defined "
i finally succeed with a mysql view which is called by a fake entity in doctrine and DQL Query .
to create a view on sql , simply execute this line :
"create view VIEWNAME YOUQUERY"
in my example :
"create view entrydataView SELECT * FROM `entrydata` GROUP BY type_id, bornInf, bornSup"