Here is my mysql table need retrieve data

total table
MPN AML Onhand Demand
2 P 300 200
2 A 300 200
3 P 100 200
3 A 300 200
4 A 200 300

here is my output need
MPN AML Onhand Demand
2 P 300 200
3 A 300 200

How to retrieve data from total table that output result i need
here is my condition alway take aml type P is priority
if Ohand > demand then
show aml type P data
then take aml type A to compare
if aml type A Ohand >demand then
show aml type A data
else ignore it don't show aml type A and P
like output i need
i have tired before but it only appear aml type either A or P data
i am using mysql database store
how to appear aml type A and P simultaneous data that output table i show
Any 1 can show me solution with vb.net ??helpful appreciated

9 Years
Discussion Span
Last Post by SheSaidImaPregy

You can do this through vb.net or you can do it through your SQL query.

If you are not going to use a stored procedure, I would recommend sorting through it from your code, and just selecting all of what you need.


<script language="vb" runat="server">
Function chkArgs(ByVal mpn As Short, ByVal aml As Char, ByVal onhand As Integer, ByVal demand As Integer)
  If aml = "P" And onhand >= demand Then
    'Do your data here
  ElseIf aml = "A" And onhand >= demand Then
    'Do your data here
  End If
End Function

Just call the function everytime you need the data. chkArgs(<%# Eval("mpn") %>,<%# Eval("aml") %>,<%# Eval("onhand") %>,<%# Eval("demand") %>)

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.