$raw_results = mysql_query("SELECT sa.tag_id,s.name ,lt.lecture_name,lt.lecturer_name,lt.dev_tag,lt.start,lt.end,sa.ads_ratio,sa.abs_hours,sa.days FROM students_absence sa INNER JOIN students s ON s.tag_id = sa.tag_id INNER JOIN lecture_table lt ON lt.id = sa.lecture_name WHERE sa.tag_id LIKE '%".$query."%' AND(`name` LIKE '%".$_SESSION['username']."%')") or die(mysql_error());
所以我需要将sa.days [Sunday = 0,Monday = 1,.....]的结果转换为字符串并将其与其他结果一起显示 任何人都可以建议
答案 0 :(得分:0)
您可以在SQL中使用case语句: -
$raw_results = mysql_query("SELECT sa.tag_id,
s.name ,
lt.lecture_name,
lt.lecturer_name,
lt.dev_tag,
lt.start,
lt.end,
sa.ads_ratio,
sa.abs_hours,
CASE sa.days
WHEN 0 THEN 'Sunday'
WHEN 1 THEN 'Monday'
WHEN 2 THEN 'Tuesday'
WHEN 3 THEN 'Wednesday'
WHEN 4 THEN 'Thursday'
WHEN 5 THEN 'Friday'
WHEN 6 THEN 'Saturday'
ELSE 'Unknown'
END AS DayName
FROM students_absence sa
INNER JOIN students s ON s.tag_id = sa.tag_id
INNER JOIN lecture_table lt ON lt.id = sa.lecture_name
WHERE sa.tag_id LIKE '%".$query."%' AND(`name` LIKE '%".$_SESSION['username']."%')") or die(mysql_error());