Skip to content

runtime error #38

Answered by iamAntimPal
Antim-IWP asked this question in Q&A
Discussion options

You must be logged in to vote

MySQL Query Review

Problem Statement

The question asked to write a MySQL query that retrieves the user_id and a formatted name from the Activity table. The formatted name should have its first letter in uppercase and the remaining letters in lowercase. The query provided was:

SELECT 
    user_id,
    CONCAT(UPPER(SUBSTR(name, 1, 1)), LOWER(SUBSTR(name, 2))) AS name
FROM Activity
ORDER BY 1 ASC;

Issue Identification

The problem was that the ORDER BY 1 ASC clause uses a column ordinal (the number 1) to indicate that the results should be sorted by the first column in the SELECT list. While this is often acceptable in many MySQL environments, some SQL environments or strict SQL modes may dis…

Replies: 3 comments

Comment options

Antim-IWP
Mar 21, 2025
Collaborator Author

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Antim-IWP
Comment options

Antim-IWP
Mar 22, 2025
Collaborator Author

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
bug Something isn't working
2 participants