Match inbound batch information according to the outbound request information

Source: Internet
Author: User
Match inbound batch information according to outbound request information
This post was last edited by lazygc520 on 2013-08-07 09:39:09

The database is divided into 3 tables, kw,vp,st begins with three tables, the first two tables represent the storage, the St begins the representative out of the library requirements. The first two tables in the storage of the joint query to obtain the Cust_no and Lotno, the library table is known stockno information and the corresponding Cust_no,stockno has a sort relationship, according to the table St in the field c1_time,c_type,adress to sort, Stockno in order, Lotno match the corresponding number of first-in, first-out, and Stockno, and the equivalent will exclude the matching lotno, the new Lotno and the next Stockno match until the quantity meets the requirements, and so on. The result of the number is the result of the MOUNT*SNP in the St table. Can you do this with the information that traverses the inbound table?

Upload Attachment address: http://download.csdn.net/detail/lazygc520/5882535

The data that is known to be in storage, the requirements of the outbound, match the batch data in the warehouse according to the outbound requirements.
For example: On the Ch_result page, ch_result.php?stockno=su13061301010, the data for the shipment batch that column.

KW,VP Table union queries get the results of Cust_no and Lotno:

$sql = "Select CONCAT (Substring_index (A.cust_no,", 1),
Substring_index (A.cust_no, ' ', -1) as cust_no,b.lotno as Lotno,
Count (B.lotno) as Lotno_count from ' Kw_manage ' as a,

Group BY Lotno ORDER by lotno ASC ";
$result = mysql_query ($sql);
$ars =array ();
while ($row = Mysql_fetch_array ($result, MYSQL_ASSOC))
{
$ars [] = $row;
}
Var_dump ($ars);

The results obtained:
Array (1) {[0]=> Array (3) {["Cust_no"]=> string (Ten) "237033aw0a" ["Lotno"]=> string (4) "3207" ["Lotno_count"]=& Gt String (3) "480"}}




Share to:


------Solution--------------------
Add an out-of-Library field to the inventory table
The field is 0 when it is in storage
The number of outbound libraries when the field is out of stock
Inbound quantity-Number of outbound stores = Quantity remaining in the batch

and
Set SELECT * FROM Tbl_name

ID num
1 20
2 20
3 30

SELECT *, (select SUM (num) from Tbl_name WHERE id<=a.id) as C from Tbl_name a

ID num c
1 20
2 20
3 70
Then column C can be used as the basis for the source of the library.
If the size of the out-of-Library wrapper is 30
Then the corresponding ID is:
Packaging 1
Packaging 2 2,3
Package 3 3, subsequent ID
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.