gpt4 book ai didi

mysql - 如何从这些mysql表中找到不匹配的记录?

转载 作者:行者123 更新时间:2023-11-29 17:54:39 25 4
gpt4 key购买 nike

我是 php/mysql 的初学者。我有两张表供商店学生和每个月的费用(月费制)。这是我的 mysql 表架构,请查看此图片。 Enter image description here

fee.stuId is student.id

应该使用什么 SQL 查询来查找未提交给定月份费用的学生列表。目前我正在使用此查询:

$query = 'Febuary 2018';

SELECT
student.id,student.first_name, student.last_name
, student.fathers_name, student.curruntClass, student.mobile, student.isRte
FROM student, fee
WHERE student.id != fee.stuId AND fee.month != '$query';

请帮忙。提前致谢。

最佳答案

以下查询将对您有所帮助,

$query = 'Febuary 2018';

$queryResult = "SELECT student.id,student.first_name, student.last_name, student.fathers_name, student.curruntClass, student.mobile, student.isRte
FROM student
WHERE student.id NOT IN ( SELECT stuId FROM fee WHERE month = '".$query."')";

关于mysql - 如何从这些mysql表中找到不匹配的记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48971001/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com