create table peckingorder(title varchar(10),loco int)
insert into table peckingorder values('Chef',100)
insert into table peckingorder values('Vice chef',200)
insert into table peckingorder values('Anställd',300)
select t.section,t.name,t.title
from telefon t
inner join peckingorder p on t.title = p.title
where section in ('SECTION1','SECTION2','SECTION3')
order by t.section,p.loco
Frågan#1
Jag har tre st sectioner(avdelningar) uppdelade i en tabell som alla har en chef, en viceoch x antal anställda. Finns det nåt sätt från annan tabell styra ordningen med titeln så att först visas chef, sedan vice chef och till sist x anställda, vilka alla får titeln anställd.
Dessa sectioner visas på följande sätt.
$query = "select * from telefon where section='SECTION1' order by id";
$query = "select * from telefon where section='SECTION2' order by id";
$query = "select * from telefon where section='SECTION3' order by id";