Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have an application called Moodle version 1.9 and was migrated from Windows platform and Microsoft SQL Server to Linux and MySQL.

Now, when I click save changes the SQL query statement from Custom SQL, it gives me "Query failed".

I would appreciate your help to advise how to fix the below SQL statement that I got from http://docs.moodle.org/22/en/ad-hoc_contributed_reports#All_Ungraded_Assignments_w.2F_Link

SELECT 
    u.firstname AS "First",
    u.lastname AS "Last",
    c.fullname AS "Course",
    a.name AS "Assignment",
    '<a href="http://moodle.domain.com/mod/assignment/submissions.php' + char(63) +
        + 'id=' + cast(cm.id AS varchar) + '&userid=' + cast(u.id AS varchar) +
        + '&mode=single&filter=0&offset=2">' + a.name + '</a>'
        AS "Assignmentlink"
FROM prefix_assignment_submissions AS asb
    JOIN prefix_assignment AS a ON a.id = asb.assignment
    JOIN prefix_user AS u ON u.id = asb.userid
    JOIN prefix_course AS c ON c.id = a.course
    JOIN prefix_course_modules AS cm ON c.id = cm.course
WHERE asb.grade < 0 
    AND cm.instance = a.id 
    AND cm.module = 1
ORDER BY c.fullname, a.name, u.lastname
share|improve this question
add comment

1 Answer

you should use concat to join strings.

this column:

'<a href="http://moodle.domain.com/mod/assignment/submissions.php' + char(63) +
+ 'id=' + cast(cm.id AS varchar) + '&userid=' + cast(u.id AS varchar) +
+ '&mode=single&filter=0&offset=2">' + a.name + '</a>'
AS "Assignmentlink"

in mysql should write as this:

concat('<a href="http://moodle.domain.com/mod/assignment/submissions.php',char(63) , 'id=' , cast(cm.id AS varchar) , '&userid=' , cast(u.id AS varchar)  , '&mode=single&filter=0&offset=2">' , a.name , '</a>')
AS "Assignmentlink"
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.