---
title: "Discussion on \"JPA MySql Random 조회  (1) - order by rand()\" | Hashnode"
description: "Discussion on \"JPA MySql Random 조회  (1) - order by rand()\". 서문\n요구사항 개발 중 데이터를 랜덤으로 조회할 필요가 생겼다.\nDB는 MySql을 사용하고 있다. Mysql은 rand()를 통해 랜덤 기능을 제공하며 데이터를 랜덤하게 조회하기 위해선 공식문서에도 나와있듯이 SELECT * FROM tbl_name ORDER BY RAND(); 와 같이 사용하면 된다.\n애플리케이션 서버에서 이를 어떻게 구현할 지가 고민이었고 Spring Boot 2.7.5, JPA, QueryDsl 을 사용중이다.\nJPQL..."
url: "https://hashnode.com/posts/jpa-mysql-random-1-order-by-rand/65a5334ec9d77f3d82b9b00e"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [JPA MySql Random 조회 (1) - order by rand()](https://hodu.hashnode.dev/jpa-mysql-random-1-order-by-rand?utm_source=hashnode&utm_medium=feed)

서문 요구사항 개발 중 데이터를 랜덤으로 조회할 필요가 생겼다. DB는 MySql을 사용하고 있다. Mysql은 rand()를 통해 랜덤 기능을 제공하며 데이터를 랜덤하게 조회하기 위해선 공식문서에도 나와있듯이 SELECT \* FROM tbl\_name ORDER BY RAND(); 와 같이 사용하면 된다. 애플리케이션 서버에서 이를 어떻게 구현할 지가 고민이었고 Spring Boot 2.7.5, JPA, QueryDsl 을 사용중이다. JPQL...

Jan 15, 2024 · 3 min read · hodu.hashnode.dev  
Updated Feb 28, 2024  
Read the article

-   [#springboot](https://hashnode.com/tag/springboot)
-   [#jpa](https://hashnode.com/tag/jpa)
-   [#mysql](https://hashnode.com/tag/mysql)
-   [#querydsl](https://hashnode.com/tag/querydsl)

## Written by

[JaeHun Kim](https://hashnode.com/@hoduulmu)

@hoduulmu

  
[View profile](https://hashnode.com/@hoduulmu)

## Responses 1

Markdown supported · ⌘↵ to post

[Taehyeong Lee](https://hashnode.com/@jsonobject)

[Jan 16, 2024](https://hashnode.com/posts/jpa-mysql-random-1-order-by-rand/65a5334ec9d77f3d82b9b00e/comment/65a630cb5c419c344d8f8ef5)

Thanks for the detailed and helpful information. :)
