Skip to content

ORDER BY not working in prepared stataments #274

Closed
@labkode

Description

@labkode

I tried to run this sql command, the query uses the limit and offser but bypass the orderBy.
In the other hand, If I wrote the query manually (SELECT * FROM partner ORDER BY id DESC) works perfectly

    // The inputs I recive are of this type orderBy string, limit, offset int64
    query := "SELECT * FROM partner ORDER BY ? LIMIT ? OFFSET ?"
    stmt, err := db.Prepare(query)
    if err != nil {
        return
    }
    defer stmt.Close()
    rows, err := stmt.Query(orderBy, limit, offset)

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