Dear Members
I have the follow table definition
Code:
CREATE TABLE item (
idItem bigint(20) unsigned NOT NULL auto_increment,
idArticulo bigint(20) unsigned NOT NULL ,
texto varchar(40),
PRIMARY KEY (idItem,idArticulo)
)ENGINE=InnoDB;
consider idArticulo like the PK from a Master table
Therefore Articulo (Master Table, Father) and Item (Sub Master Table, child)
Here to fill with simple data
Code:
insert into item(idArticulo,texto)values(1,'one');
insert into item(idArticulo,texto)values(1,'two');
insert into item(idArticulo,texto)values(1,'three');
insert into item(idArticulo,texto)values(2,'one');
insert into item(idArticulo,texto)values(2,'two');
insert into item(idArticulo,texto)values(2,'three');
If I do the follow query, I get
Code:
mysql> select idarticulo,iditem,texto from item order by iditem,idarticulo;
+------------+--------+-------+
| idarticulo | iditem | texto |
+------------+--------+-------+
| 1 | 1 | one |
| 1 | 2 | two |
| 1 | 3 | three |
| 2 | 4 | one |
| 2 | 5 | two |
| 2 | 6 | three |
+------------+--------+-------+
6 rows in set (0.00 sec)
mysql>
I want some way, if is necessary edit the table no problem, to get something like this (desired output)
Code:
+------------+--------+-------+
| idarticulo | iditem | texto |
+------------+--------+-------+
| 1 | 1 | one |
| 1 | 2 | two |
| 1 | 3 | three |
| 2 | 1 | one |
| 2 | 2 | two |
| 2 | 3 | three |
+------------+--------+-------+
I mean, each Master table has its own control from its childs
I need this solution to apply too for warehouse documentation control, something like
Code:
+------------+------------------+-------+
| series | warehouse-number | type |
+------------+------------------+-------+
| 1 | 1 | in |
| 1 | 2 | out |
| 1 | 3 | in |
| 2 | 1 | out |
| 2 | 2 | out |
| 2 | 3 | out |
+------------+------------------+-------+
Thanks in advanced for your guidance