I have problem to create sql statement.
The situation is like this:
I have 2 tables;
03user_report ----> user report their problem
04report_status --> track down the process of solving the problem (who do what)
03user_report
id | user_id | status
01 | a001 | new
02 | b002 | in process
03 | b003 | kiv
04 | a006 | new
04report_status
id | staf_id | status
02 | a001 | in process
03 | a003 | kiv
02 | a005 | in process
Situation:
1) a001 is a staff. a001 make a report and get an id no. 01.
b002 is a user. b002 make a report and get an id no. 02.
a006 is a staff. a006 make a report and get an id no. 04.
2) report id no. 01 is not assign to anyone yet.
report id no. 02 is assign to staff no. a001 and the status is new.
report id no. 04 is not assign to anyone yet.
3) staff no. a001 can't solve report id no. 02 and pass it to staff no. a005.
I want to view report by a001 & a006 as well as the report that a001 in charge.
eg: view by a001
report_id |
01 | (report by a001)
02 | (report that a001 incharge before pass it to a005)
eg: view by a006
report_id |
04 |
My sql statement:
(This statement is true only for a001)
SELECT * FROM 03user_report, 04report_status
WHERE (03user_report.user_id='$GET[s_id]' || 04report_status.staf_if='$GET[s_id]');
Then I try to use 'IF' in my statement:
SELECT * FROM 03user_report, 04report_status
WHERE IF (03user_report.user_id='$GET[s_id]', 03user_report.user_id='$GET[s_id]', '')
AND IF (04report_status.staf_if='$GET[s_id]', 04report_status.staf_if='$GET[s_id]', '');
(But, nothing came out. Maybe my code is wrong.)
I want to use 'CASE' but I don't know how.