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
output
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
else
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
thx

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.

SELECT * FROM tbl

<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
</script>

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

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.