mediaholic
Fri 31st Oct '03, 1:02pm
hi outthere,
i have problem with order by , the problem is following:
my tbl looks like:
CREATE TABLE menu (
id int(10) unsigned NOT NULL auto_increment,
p_id int(10) unsigned default NULL,
o_id int(10) unsigned default NULL,
label varchar(20) default NULL,
PRIMARY KEY (id)
) TYPE=MyISAM;
#
and there r this values inside:
INSERT INTO menu (p_id, o_id, label)
VALUES(NULL, 1, 'autos'),
(NULL, 2, 'motoren'),
(1, 3, 'pkw'),
(1, 4, 'lkw'),
(3, 5, 'vw') ;
(NULL, 6, 'vw') ;
#
my query is:
$sql="SELECT c.label as lab FROM";
$sql.=" menu p INNER JOIN menu c USING(id)";
$sql.=" ORDER BY p.o_id and p.p_id";
i wont to get followin output:
autos
pkw
vw
lkw
motoren
pcs
but i dont know how to handel this order by with inner join.
i m alway geting
autos
motoren
pcs
pkw
vw
lkw
or
autos
motoren
pkw
vw
lkw
pcs
i m running mysql 3.23.xx
CAN ANYBODY HELP???
i have problem with order by , the problem is following:
my tbl looks like:
CREATE TABLE menu (
id int(10) unsigned NOT NULL auto_increment,
p_id int(10) unsigned default NULL,
o_id int(10) unsigned default NULL,
label varchar(20) default NULL,
PRIMARY KEY (id)
) TYPE=MyISAM;
#
and there r this values inside:
INSERT INTO menu (p_id, o_id, label)
VALUES(NULL, 1, 'autos'),
(NULL, 2, 'motoren'),
(1, 3, 'pkw'),
(1, 4, 'lkw'),
(3, 5, 'vw') ;
(NULL, 6, 'vw') ;
#
my query is:
$sql="SELECT c.label as lab FROM";
$sql.=" menu p INNER JOIN menu c USING(id)";
$sql.=" ORDER BY p.o_id and p.p_id";
i wont to get followin output:
autos
pkw
vw
lkw
motoren
pcs
but i dont know how to handel this order by with inner join.
i m alway geting
autos
motoren
pcs
pkw
vw
lkw
or
autos
motoren
pkw
vw
lkw
pcs
i m running mysql 3.23.xx
CAN ANYBODY HELP???