Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to get the value between the intersection of row and column.
For example, the condition is if Model1 and Plan999 it should get 1200 value or if Model1 and Plan 1200 get 600 value. what is the query to use using mysql as backend and vb.net as frontend.

id | Plan 999 | Plan 1200
------------------------------------
Model1 | 1200 | 300
Model2 | 1300 | 600
Posted
Comments
DamithSL 27-Nov-14 22:19pm    
what have you tried so far?
try to build your sql statement with with the user selected conditions and then you can set the parameter values. execute the sql statement and fetch the results.

1 solution

you can create sql statement which
VB
'inputs 
Dim id As String = "Model1"
Dim plan999 As Integer = 1200
Dim plan1200 As Integer = 0
'based on inputs try to select the columns which you want and also change the where condition based on the condition 
Dim sql As String = "select id, CASE when @Plan999 = 0 then [Plan 1200] else [Plan 999] END CASE from TableName where id =@id and (@Plan999 = 0 Or [Plan 999] = @Plan999) and (@Plan1200 = 0 Or [Plan 1200] = @Plan1200)"
' create SqlCommand with about sql and set the parameter value 
'Finally execute it and take the results.

Hope this will help you to get started
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900