PostgreSQL(14)
-
PostgreSQL WITH RECURSIVE 배열로 데이터 전달하기
WITH RECURSIVE category_hierarchy AS ( -- Base case: Select root nodes SELECT id, name, parent_id, ARRAY[name] AS path, -- Start hierarchy path as an array ARRAY[x,y,width,height] AS rectData, -- Start hierarchy path as an array 1 AS level FROM categories WHERE parent_id IS NULL UNION ALL -- Recursive case: Append child nodes to hierarchy ..
2025.01.30 -
PostgreSQL WITH RECURSIVE과 ARRAY를 사용하여, hierarchy 구조 테이블 데이터 보여주기
쿼리WITH RECURSIVE category_hierarchy AS ( -- Base case: Select root nodes SELECT id, name, parent_id, ARRAY[name] AS path, -- Start hierarchy path as an array 1 AS level FROM categories WHERE parent_id IS NULL UNION ALL -- Recursive case: Append child nodes to hierarchy SELECT c.id, c.name, c.parent_id, ch.path ..
2025.01.29 -
PostgreSQL outer join
Left outer join: a 기준으로 다 나옴SELECT a.id AS table_a_id, a.name AS table_a_name, b.id AS table_b_id, b.description AS table_b_descriptionFROM table_a aLEFT OUTER JOIN table_b b ON a.id = b.a_id;table_a_id | table_a_name | table_b_id | table_b_description-----------+-------------+------------+----------------------1 | Apple | 1 | Fruit2 | Carrot ..
2025.01.29 -
PostgreSQL 'desc'도 키워드임
컬럼명에 사용하면 에러 발생함
2025.01.04 -
PostgreSQL update문 처리
','에 상관없이 작동함 UPDATE users name = #{name}, email = #{email}, age = #{age}, WHERE id = #{id}위에 것이 안되는 경우 UPDATE users name = #{name}, email = #{email}, age = #{age}, WHERE id = #{id}
2024.12.28 -
PostgreSQL 컬럼명에 'table'을 사용하면 에러 발생함
쿼리insert into test(table)values('00');에러ERROR: syntax error at or near ")"LINE 1: insert into test(table) ^정상insert into test("table")values('00');
2024.12.28