Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sortBy RAND() #813

Closed
ellvinib opened this issue Sep 1, 2017 · 2 comments
Closed

sortBy RAND() #813

ellvinib opened this issue Sep 1, 2017 · 2 comments

Comments

@ellvinib
Copy link

ellvinib commented Sep 1, 2017

Hi,
Is it possible use the RAND function ?
i want to use in sql ORDER BY RAND()

When i use addOrderBy('RAND()')

got : Error: ER_BAD_FIELD_ERROR: Unknown column 'distinctAlias.RAND()_undefined' in 'field list'

@pleerock
Copy link
Member

pleerock commented Sep 6, 2017

Can you provide a complete code example? I checked following and it works:

        const posts = await connection.createQueryBuilder(Post, "post")
            .orderBy("RAND()")
            .getMany();

Also what typeorm version are you using?

@pleerock
Copy link
Member

pleerock commented Sep 8, 2017

Closing it because i cannot reproduce it, please update typeorm to latest version and check this issue once again and let me know if you still have this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants