简体   繁体   English

基于mysql中的另一个表单元格值排除的行

[英]Excluded row based on a another table cell value in mysql

I have two tables. 我有两张桌子。

student master 学生大师 在此输入图像描述 Feemaster Feemaster 在此输入图像描述 I executed the query 我执行了查询

SELECT f.standard,fee_type,fee_name,amount,ac_year FROM fee_master f, student_master s
where
s.standard=f.standard and
s.admission_no='21300';

I got resultset like 我得到了结果集 在此输入图像描述

But my need is if studnet_master.ac_year== AC16 then INITIAL FEE should get removed from resultset or if studnet_master.ac_year== !=AC16 then ADMISSION FEE should get removed from resultset 但是,我需要的是 ,如果studnet_master.ac_year == AC16然后加盟费应该得到的结果集,或者去掉studnet_master.ac_year ==!= AC16然后入场费应该从ResultSet中删除

Can anyone please help me to sort out this.... 任何人都可以帮我解决这个问题....

Thanks in advance... 提前致谢...

Just add two extra conditions to your WHERE clause: 只需在WHERE子句中添加两个额外条件:

SELECT f.standard, f.fee_type, f.fee_name, f.amount, s.ac_year
FROM fee_master f
INNER JOIN
student_master s
    ON s.standard = f.standard
WHERE s.admission_no = '21300' AND
    (s.ac_year != 'AC16' OR f.fee_name != 'INITIAL FEES') AND
    (s.ac_year = 'AC16' OR f.fee_name != 'ADMISSION FEES')
You can put condition in and statement.
Query:-
SELECT f.standard,fee_type,fee_name,amount,ac_year FROM fee_master f, student_master s
where
s.standard=f.standard and
s.admission_no='21300' and
IF(s.ac_year = 'AC16',FEE_NAME != 'INITIAL FEES',FEE_NAME != 'ADMISSION FEES')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM