我有两张桌子:
tbl_fee_payment_history
pk_int_fph_id fk_int_student_id int_fph_amount dat_fph_date
1 1 10000 2013-12-11
2 2 5000 2013-11-11
3 1 5000 2013-12-16
4 3 5000 2013-10-19
tbl_students
pk_int_student_id fk_int_user_id vchr_student_name
1 2 alex
2 3 johnson
3 4 ram
4 5 mary
如何创建存储过程以查找学生的姓名,在特定月份和年份支付的费用
如:csp_students(2013,10);
结果:
.name.
mary
答案 0 :(得分:0)
SELECT s.`vchr_student_name` FROM
tbl_fee_payment_history f
INNER JOIN tbl_students s
ON f.`fk_int_student_id` = s.`pk_int_student_id`
WHERE YEAR(`dat_fph_date`) = 2013 AND
MONTH(`dat_fph_date`) = 10
获取dayname有一个mysql方便的功能 DAYNAME
mysql> SELECT DAYNAME('2007-02-03');
-> 'Saturday'