MySQL Forums
Forum List  »  InnoDB

Re: Help on Query with DATE BETWEEN not performant
Posted by: Kristijan Marin
Date: February 06, 2020 04:31PM

>
>
> SELECT A.*
> ,E.fk_media,E.nrscanpages,E.dateOfArticle,E.createdate,E.ID,E.title,E.body,E.subtitle,E.author,E.summary
> FROM
> (SELECT CA.* from econtracts_articles AS CA
> WHERE CA.fk_econtract IN (SELECT fk_contract FROM
> ecust_user_contract WHERE fk_cust_user='ukommiha')
> AND CA.articledate BETWEEN '2018.01.01' AND
> '2020.02.02') as A
> JOIN earticles AS E ON A.fk_earticle = E.ID
> WHERE (UPPER(CONCAT_WS(title,' ',subtitle,'
> ',body,' ',author,' ',summary)) LIKE '%drzava%' )
> GROUP BY E.id ORDER BY E.dateOfArticle ASC LIMIT
> 0,10
>
>


Sorry a copy/paste error, no need for "group by" when I have distinct in a subquery (no difference for those 10 rows after) :

SELECT A.* ,E.fk_media,E.nrscanpages,E.dateOfArticle,E.createdate,E.ID,E.title,E.body,E.subtitle,E.author,E.summary
FROM 
(SELECT DISTINCT CA.* from econtracts_articles AS CA 
WHERE CA.fk_econtract IN (SELECT fk_contract FROM ecust_user_contract WHERE fk_cust_user='ukommiha') AND CA.articledate BETWEEN '2018.01.01' AND '2020.02.02') as A
JOIN earticles AS E ON A.fk_earticle = E.ID 
WHERE (UPPER(CONCAT_WS(title,' ',subtitle,' ',body,' ',author,' ',summary)) LIKE '%drzava%' )   ORDER BY E.dateOfArticle ASC LIMIT 0,10

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Help on Query with DATE BETWEEN not performant
33
February 06, 2020 04:31PM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.