select distinct records after performing join

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phpgurullc
    New Member
    • Aug 2009
    • 3

    select distinct records after performing join

    i have two tables a,b,..with approximately 2lac records in each,..

    table a
    --------------------
    a_id a_title

    5 abc

    6 xyz

    table b
    ---------------------------
    b_id a_id

    123 5
    123 6



    i want all the records from table a having distinct a_title which matches with table b,the query i am trying is

    select b.b_id, a.a_title,GROUP _CONCAT(a.id) as id from a inner join b on a.a_id=b.b_id where b.b_id=123 group by a.a_title

    the above query is taking lots of time,kindly suggest an optimized way for this.
  • dgreenhouse
    Recognized Expert Contributor
    • May 2008
    • 250

    #2
    I'm unclear on why you're using the group_concat...

    Maybe this will help:
    Code:
    select b.id,a.title from tablea a
    join tableb b on b.id = a.id
    where b.id=123
    group by a.title order by b.id

    Comment

    Working...