hi all,
i created a table like this
CREATE TABLE group_tbl (
group_id tinyint(8) unsigned NOT NULL auto_increment,
group_name varchar(255) default '0',
group_email varchar(255) default '0',
parent_id int(8) unsigned NOT NULL default '0',
group_status enum('1','0') default '0',
group_descr text,
PRIMARY KEY (group_id)
) TYPE=MyISAM;
in this i can create groups and subgroups .when i create subgroup main group id will come to parent id field.otherwise it remains 0.The problem is i want to display results in the followng way
id group_name group_email main group
1 maingroup 1 maingroup1@gp.com
2 subgroup 1-1 subgroup1-1 @gp.com maingroup 1
3 subgroup 1-2 subgroup1-2 @gp.com maingroup 1
4 main_group 2 maingroup2@gp.com
5 subgroup 2-1 subgroup2-1 @gp.com maingroup 2
6 subgroup 2-2 subgroup2-2 @gp.com maingroup 2
7 subgroup 2-3 subgroup2-3 @gp.com maingroup 2
8 subgroup 2-4 subgroup2-4 @gp.com maingroup 2
can someone help me to give the query for this