sql - SQLite - Joining Rows in the same Table -
sql - SQLite - Joining Rows in the same Table -
i have table next columns
id - personid - orderedid - postageid - recorddate - operatorid personid - refers table cotaining firstname, secondname etc. orderedid - refers table of items can order. postageid - enum. recorddate - timedate made order. operatorid - phone operator made order.
if @ time orders 2 or 3 items @ same time 2 or 3 rows entered table, personid, recorddate , operatorid same. can order unto 8 items @ same time.
now have construction next layout.
order: first name sec name orderedid 1 name orderedid 1 colour orderedid 1 weight orderedid 2 name orderedid 2 colour orderedid 2 weight orderedid 3 name orderedid 3 colour orderedid 3 weight orderedid 4 name orderedid 4 colour orderedid 4 weight orderedid 5 name orderedid 5 colour orderedid 5 weight orderedid 6 name orderedid 6 colour orderedid 6 weight orderedid 7 name orderedid 7 colour orderedid 7 weight orderedid 8 name orderedid 8 colour orderedid 8 weight orderdate orderuser
how can build sql query combines rows in table if personid , recorddate , operatorid same, gives me total list of orderedid details.
if have table 'table' rows 'value', 'category' use:
select t1.value cat1, t2.value cat2, table t1, table t2 t1.category='cat1' t2.category='cat2'
so have utilize similar to
select p.f_name, p.s_name, o1.name, o1.color, o2.name, o2.color persons p, table t, orders o1, orders o2 t.personid = p.id , o1.id=t.orderedid , o2.id=t.orderedid , ...
sql sqlite
Comments
Post a Comment