|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I want to optimize my query. Is there such tool available for MySQL?
Thanks, Here is a sample query: select id, username, role, first_name,last_name,email from users where id in (select distinct user_id from user_enrols where course_id in (select distinct course_id from user_courses where user_id=2) and role='S' and username like '%1%') |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Steveston wrote:
> I want to optimize my query. Is there such tool available for MySQL? > > Thanks, > > Here is a sample query: > > select id, username, role, first_name,last_name,email from users where > id in > (select distinct user_id from user_enrols where course_id in > (select distinct course_id from user_courses where user_id=2) and > role='S' and username like '%1%') > > EXPLAIN. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Nov 7, 6:14 pm, Steveston <minghu...@gmail.com> wrote:
> I want to optimize my query. Is there such tool available for MySQL? > > Thanks, > > Here is a sample query: > > select id, username, role, first_name,last_name,email from users where > id in > (select distinct user_id from user_enrols where course_id in > (select distinct course_id from user_courses where user_id=2) and > role='S' and username like '%1%') Yeah -- there's no point in using "distinct" inside those sub- queries. That's one reason to use an "in" clause in the first place. Having said that, if you don't have a specific reason for using the "in" clause use a join instead. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On 7 Nov, 23:14, Steveston <minghu...@gmail.com> wrote:
> I want to optimize my query. Is there such tool available for MySQL? > > Thanks, > > Here is a sample query: > > select id, username, role, first_name,last_name,email from users where > id in > (select distinct user_id from user_enrols where course_id in > (select distinct course_id from user_courses where user_id=2) and > role='S' and username like '%1%') JOINS? |
|
![]() |
| Outils de la discussion | |
|
|