Description:
I have a case in finding a solution to a problem. rules to find the solution as follows:
Case 1:
IF T01 AND T02 AND T03 THEN S01
Case 2:
IF T04 THEN S02
Case 3:
IF T04 AND T05 AND T06 THEN S03
To display the questions on the matter, set based on a decision tree. at the time of problem 1 (T1) asked, then there is a yes or no answer. if you have problems, a selected 'yes'. if it does not have this problem, then selected the answer 'no'. followed by asking about the next problem until a solution (S) is found.
My question:
please see the decision tree on the following link here .
Caption:
T = trouble/problem;
S = solution;
Y = if answer is YES;
N = if answer is NO;
Thank you
This could be achieved with something like:
-----------------------------------------------------
| decisionId | ifTrueDecisionId | ifFalseDecisionId |
=====================================================
| T01 | T02 | T04 |
-----------------------------------------------------
| T02 | T03 | S0 |
-----------------------------------------------------
| T03 | S1 | S0 |
-----------------------------------------------------
| T04 | T05 | S0 |
-----------------------------------------------------
And so on....
You can then do a SQL query based on the Trouble/Problem stated. The result gives you directions for a new question. Where again you query for the next step.
SELECT
...,
IF(T01,
IF(T02,
IF(T03,
S01,
S0
),
S0
),
IF(T04,
IF(T05,
IF(T06,
S03,
S0,
),
S02
),
S0
)
) AS some_field_alias
...
according to http://oi59.tinypic.com/24cw9ye.jpg
using this http://dev.mysql.com/doc/refman/5.1/en/control-flow-functions.html#function_if
You can use this logic right in mysql query. Each T* could be a sub-request as well as S*.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.