0

table items
barcode
quantity
price
id

table serial_number
barcode
serial_number
id

table items_out
barcode
serial_number
quantity
price
id

i have three table just like i describe above. if i choose a barcode and quantity=2 from table items and i want to move 2 serial_number from table serial_number to table items_out, how to write it in sql?

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by harrysuke
0

table items
barcode
quantity
price
id

table serial_number
barcode
serial_number
id

table items_out
barcode
serial_number
quantity
price
id

i have three table just like i describe above. if i choose a barcode and quantity=2 from table items and i want to move 2 serial_number from table serial_number to table items_out, how to write it in sql?

Firstly, why one more table with only one extra field serial_number in it? You can add that field to the table_items!

string serialvar, barcodevar='ur-barcode';
int quantityvar=2, pricevar='ur-price',id='ur-id-value';

serialvar = "SELECT serial_number FROM   serial_number WHERE barcode = 'barcodevar'";

INSERT INTO   items_out (barcode,serial_number,quantity,price,id) VALUES("barcodevar","serialvar","quantityvar","pricevar","idvar");

Didn't try this query but hopeful it solves the problem.
Corrections are always Welcome :)

0

i didn't know that someone will reply very quickly. btw i have change my code. but thanks again csharplearner :D

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.