Yii Framework Forum: Sql Query Optimazation - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Sql Query Optimazation Rate Topic: -----

#1 User is offline   maher 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 69
  • Joined: 31-July 12
  • Location:Edmonton

Posted 30 November 2012 - 05:59 AM

Hi

I have this query
and i want to optimize this query (here I use a SELECT and SUB SELECT) and use only one SELECT if possible

Does anyone have any Idea about it.

Thank you in advance

SELECT c.*
FROM course AS c
JOIN student_course AS sc
ON c.id = uc.course_id
WHERE sc.student_id = '5' AND c.level = (SELECT MAX(level) 
                                         FROM course  
                                         JOIN student_course 
                                         ON c.id = sc.course_id)
GROUP BY c.category_id 

0

#2 User is offline   Allan Freitas 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 38
  • Joined: 08-November 12
  • Location:Guarapari-ES - Brazil

Posted 30 November 2012 - 05:57 PM

Maher,

It's possible. What Database are you using?

Can You provide sql create tables and inserts(exemples) for the case?


View Postmaher, on 30 November 2012 - 05:59 AM, said:

Hi

I have this query
and i want to optimize this query (here I use a SELECT and SUB SELECT) and use only one SELECT if possible

Does anyone have any Idea about it.

Thank you in advance

SELECT c.*
FROM course AS c
JOIN student_course AS sc
ON c.id = uc.course_id
WHERE sc.student_id = '5' AND c.level = (SELECT MAX(level) 
                                         FROM course  
                                         JOIN student_course 
                                         ON c.id = sc.course_id)
GROUP BY c.category_id 


0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users