Hi,
I have question about SELECT and INSERT combination. Suppose that I have these tables:
Type: Status: Order:
ID | Type ID | Status ID | Order
---+----- ---+------- ---+------
1 | A 1 | B 1 | C
File:
ID | Order_ID | Type_ID | Status_ID | Filename
---+----------+---------+-----------+---------
1 | 1 | 1 | 1 | abc.txt
and I want to insert a new record in File table. I know the type, status, and order.
Currently I make 3 queries, each to get Order_ID, Type_ID, Status_ID, then insert the new record. Is there any way faster than this? I know that I can use 'INSERT INTO table (col1, col2) SELECT col1, col2 FROM other_table'. But it only works if I can get all the inserted columns from other tables. Here, I gat the Filename field from other process which doesn't use database.
Can anyone help? Thank's in advance
I have question about SELECT and INSERT combination. Suppose that I have these tables:
Type: Status: Order:
ID | Type ID | Status ID | Order
---+----- ---+------- ---+------
1 | A 1 | B 1 | C
File:
ID | Order_ID | Type_ID | Status_ID | Filename
---+----------+---------+-----------+---------
1 | 1 | 1 | 1 | abc.txt
and I want to insert a new record in File table. I know the type, status, and order.
Currently I make 3 queries, each to get Order_ID, Type_ID, Status_ID, then insert the new record. Is there any way faster than this? I know that I can use 'INSERT INTO table (col1, col2) SELECT col1, col2 FROM other_table'. But it only works if I can get all the inserted columns from other tables. Here, I gat the Filename field from other process which doesn't use database.
Can anyone help? Thank's in advance