Yii Framework Forum: Join Of Two Table And Get The Distinct Records With Three Fields - Yii Framework Forum

Jump to content

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

Join Of Two Table And Get The Distinct Records With Three Fields

#1 User is offline   Nilesh287 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 10-February 13

Posted 24 April 2013 - 01:40 PM

Join of two table and get the distinct records with three fields.

I want to retrieved all the fields from two tables using join and apply distinct clause on three fields.

eg.
I have table User which has fields id,name,lastname,dob
and another table education_info id, id_user(which is reference of user table),school_name,addresss.

I have to retrieved the fields name,lastname,dob,school_name,address in which following fields are distinct name,lastname and shool_name.

Help appreciated :)
0

#2 User is offline   Ravi Bhalodiya 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 64
  • Joined: 27-August 12
  • Location:Gujarat India

Posted 12 July 2013 - 04:58 AM

Hey try this...

select 
(SELECT group_concat(DISTINCT a) FROM my_table) as a,
(SELECT group_concat(DISTINCT B) FROM my_table) as b,
(SELECT group_concat(DISTINCT c) FROM my_table) as c,
(SELECT group_concat(DISTINCT d) FROM my_table) as d

Regards
Ravi Bhalodiya.
0

#3 User is offline   nomibucha100 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 11-October 13

Posted 11 October 2013 - 01:38 AM

thanks for the nice sharing
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