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?

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 :)

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.