Bibi's DevLog ๐Ÿค“๐ŸŽ

[MySQL] function does not exist ์˜ค๋ฅ˜ ๋ฐœ์ƒ ์‹œ ํ•ด๊ฒฐ๋ฒ• / ์ค‘๋ณต๋˜๋Š” ๋‚ ์งœ๊ฐ€ ์—†๋„๋ก ๋‚ ์งœ ์กฐํšŒํ•˜๊ธฐ ๋ณธ๋ฌธ

๐Ÿ–ฅ BE ๋ฐฑ์—”๋“œ/Database

[MySQL] function does not exist ์˜ค๋ฅ˜ ๋ฐœ์ƒ ์‹œ ํ•ด๊ฒฐ๋ฒ• / ์ค‘๋ณต๋˜๋Š” ๋‚ ์งœ๊ฐ€ ์—†๋„๋ก ๋‚ ์งœ ์กฐํšŒํ•˜๊ธฐ

๋น„๋น„ bibi 2021. 5. 28. 22:19

[MySQL] function does not exist ์˜ค๋ฅ˜ ๋ฐœ์ƒ ์‹œ ํ•ด๊ฒฐ๋ฒ•..

์ถœ์ฒ˜๐Ÿ™‡โ€โ™‚๏ธ

https://sharehan.tistory.com/entry/MySql%EC%82%AC%EC%9A%A9-%EC%8B%9C-function-does-not-exist-%EC%98%A4%EB%A5%98%EB%B0%9C%EC%83%9D-%EC%8B%9C

java sql SqlsyntaxErrorException FUNCTION ... ์˜ ์›์ธ

: ์ฟผ๋ฆฌ๋ฌธ์— ์˜ฌ๋ฐ”๋ฅด์ง€ ๋ชปํ•œ ๋„์–ด์“ฐ๊ธฐ๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธํ•œ๋‹ค.

String sql = "select booking.id, room_id, user_id, check_in, check_out, number_of_people, total_price" +
                " from `booking` left join `room` on room_id = room.id" +
                " where room_id = ? and " +
                " (? between check_in and check_out and ? > check_out)";

.. and (? between check_in ...)์˜ and์™€ ๊ด„ํ˜ธ ์‚ฌ์ด์— ๋„์–ด์“ฐ๊ธฐ๊ฐ€ ๋‘ ๋ฒˆ ๋˜์–ด ์žˆ๋‹ค.

์œ„ ์ฟผ๋ฆฌ๋ฌธ์ฒ˜๋Ÿผ ์ž˜๋ชป ์ž‘์„ฑํ•˜๋ฉด function does not exist ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋‹ค.

๊ทธ๋ž˜๋„ ํ•ด๊ฒฐ๋˜์ง€ ์•Š๋Š”๋‹ค๋ฉด ์ถœ์ฒ˜ ๋งํฌ๋ฅผ ์ฐธ๊ณ ํ•ด mysql์—์„œ Space Ignore์„ค์ •์ด ์ž˜๋ชป ๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธํ•œ๋‹ค.

[MySQL] ์ค‘๋ณต๋˜๋Š” ๋‚ ์งœ๊ฐ€ ์—†๋„๋ก ๋‚ ์งœ ์กฐํšŒํ•˜๊ธฐ

์ถœ์ฒ˜๐Ÿ™‡โ€โ™‚๏ธ

https://way-be-developer.tistory.com/54

์ˆ™์†Œ ๊ฒ€์ƒ‰ ์„œ๋น„์Šค์—์„œ ๊ธฐ์กด ์˜ˆ์•ฝ๋“ค์˜ ์ฒดํฌ์ธ~์ฒดํฌ์•„์›ƒ ๋‚ ์งœ์™€ ๊ฒน์น˜์ง€ ์•Š๋Š”์ง€ ํ™•์ธํ•  ๋•Œ ์‚ฌ์šฉํ–ˆ๋‹ค.

๋‚ ์งœ ์ค‘๋ณตํ™•์ธ ์ฟผ๋ฆฌ..

(์ฃผํ™ฉ์ƒ‰ = ์‚ฌ์šฉ์ž ์ž…๋ ฅ, ์ดˆ๋ก์ƒ‰ = ๊ธฐ์กด ์˜ˆ์•ฝ)

์•„๋ž˜ 4๊ฐ€์ง€ ์กฐ๊ฑด ์ค‘ ์ตœ์†Œ ํ•˜๋‚˜๋ฅผ ๋งŒ์กฑํ•ด์•ผ ํ•จ

1

  • ์ž…๋ ฅ ์ฒดํฌ์ธ between ๊ธฐ์กด ์ฒดํฌ์ธ and ๊ธฐ์กด ์ฒดํฌ์•„์›ƒ
  • ์ž…๋ ฅ ์ฒดํฌ์•„์›ƒ > ๊ธฐ์กด ์ฒดํฌ์•„์›ƒ

2

  • ์ž…๋ ฅ ์ฒดํฌ์ธ < ๊ธฐ์กด ์ฒดํฌ์ธ
  • ์ž…๋ ฅ ์ฒดํฌ์•„์›ƒ between ๊ธฐ์กด ์ฒดํฌ์ธ and ๊ธฐ์กด ์ฒดํฌ์•„์›ƒ

3

  • ์ž…๋ ฅ ์ฒดํฌ์ธ between ๊ธฐ์กด ์ฒดํฌ์ธ and ๊ธฐ์กด ์ฒดํฌ์•„์›ƒ
  • ์ž…๋ ฅ ์ฒดํฌ์•„์›ƒ between ๊ธฐ์กด ์ฒดํฌ์ธ and ๊ธฐ์กด ์ฒดํฌ์•„์›ƒ

4

  • ์ž…๋ ฅ ์ฒดํฌ์ธ < ๊ธฐ์กด ์ฒดํฌ์ธ
  • ์ž…๋ ฅ ์ฒดํฌ์•„์›ƒ > ๊ธฐ์กด ์ฒดํฌ์•„์›ƒ
  • SQL๋ฌธ์œผ๋กœ ๋ณ€ํ™˜ํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™์Œ
select booking.id, room_id, user_id, check_in, check_out, number_of_people, total_price from `booking` left join `room` on room_id = room.id 
where room_id = ? 
and (? between check_in and check_out and ? > check_out) 
or (? < check_in and ? between check_in and check_out) 
or (? between check_in and check_out and ? between check_in and check_out) 
or (? < check_in and ? > check_out)";