Skip to content

Function or statement for Order by clauses #821

Closed
@LazyRichard

Description

@LazyRichard

I'm not sure this is standard SQL or not. but this is useful when using MySQL.

SELECT * 
FROM mytable
WHERE id IN (3,2,1,4)
 ORDER BY FIELD(id,3,2,1,4)

or other database like MSSQL

SELECT *
FROM mytable
WHERE id IN (3,2,1,4)
ORDER BY
    CASE id
        WHEN 3 THEN 1
        WHEN 2 THEN 2
        WHEN 1 THEN 3
        WHEN 4 THEN 4
    END

the above cases supported?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions