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. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

you should use concat to join strings.

this column:

'<a href="' + char(63) +
+ 'id=' + cast( AS varchar) + '&userid=' + cast( AS varchar) +
+ '&mode=single&filter=0&offset=2">' + + '</a>'
AS "Assignmentlink"

in mysql should write as this:

concat('<a href="',char(63) , 'id=' , cast( AS varchar) , '&userid=' , cast( AS varchar)  , '&mode=single&filter=0&offset=2">' , , '</a>')
AS "Assignmentlink"
share|improve this answer

Your Answer


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.