

Not a MySQL guy but this code should be fairly close to what you need. (select id, duration from course order by duration asc) yīasically, I placed your query inside a subquery and applied the generic expression. But How would I work this around my code as so select id, duration, := + 1 as position from (select := 0) x, (select id, duration from course order by duration asc) y SELECT id,CONCAT(position,IF(MOD(position,100) IN (11,12,13),'th', Besides using spaces for string concatenation, MySQL provides two other functions that concatenate string values: CONCAT and CONCATWS. Hey Rolando, I understand roughly how you have implemented this. In Microsoft SQL server, you use the addition arithmetic operator (+) to concatenate string values. UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) U) A (SELECT 0 u UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4

UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) T, (SELECT 0 t UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) H, (SELECT 0 h UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) TH, (SELECT 0 th UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 To test this out, run the following SELECT CONCAT(num,IF(MOD(num,100) IN (11,12,13),'th', All other two-digit combinations have th appended.If the last digit of a number is 3 (other than last two digits being 13), rd is appended.


If you’re concatenating more than two strings, and you need a space (or other separator), consider using the CONCAT_WS() function. So if we apply this to a database, then the query might look something like this: SELECT CONCAT(FirstName, ' ', LastName) AS 'Full Name' Which may or may not be the result you’re looking for. If I didn’t add the space it would’ve looked like this: SELECT CONCAT('Homer', 'Simpson') AS 'Full Name'
MYSQL CONCAT STRING WITH COLUMN VALUE PLUS
I concatenated the first name, the last name, plus a space. Note that I actually concatenated 3 strings here. Here’s an example: SELECT CONCAT('Homer', ' ', 'Simpson') AS 'Full Name' In MySQL (and in any computer programming environment), string concatenation is the operation of joining character strings end-to-end. MySQL has the CONCAT() function, which allows you to concatenate two or more strings. The function actually allows for one or more arguments, but its main use is to concatenate two or more strings.
