Things to note to Mysql to PostgreSQL
- ifnull() and COALESCE()
mysql--ifnull() changepg--COALESCE() ps: mysql -- ifnull(a.audit_result, '') pgsql -- COALESCE(a.audit_result, '')
- date_format() and to_date()
mysql--date_format() changepg--to_date(),Declaration type ‘ ::text' ps: // '%' cannot be used in the pg database, such as %y-%m-%dto_date(create_time::text, 'YY-MM-DD')
- find_in_set() and ANY (string_to_array('', ','))
mysql--find_in_set() changepg--ANY (string_to_array(some_column, ',')) ps: SELECT t.dept_id FROM sys_dept t WHERE find_in_set('100', ancestors) SELECT t.dept_id FROM sys_dept t WHERE '100' = ANY (string_to_array(ancestors, ','))
- sysdate() and now()
mysql--sysdate() changepg--now()
- Fuzzy Matching
// If using the concat parameter, the pg database needs to configure the invisible conversion typemysql-- like concat('%', #{testItem}, '%') changepg-- ilike '%'|| #{testItem} ||'%' or like concat('%', #{testItem}, '%')
- GROUP_CONCAT() and string_agg()
mysql-- GROUP_CONCAT() changepg-- array_to_string(array_agg(),',') or string_agg(,',')
- locate() and strpos()
mysql-- locate() changepg-- strpos()
Summarize
The above is personal experience. I hope you can give you a reference and I hope you can support me more.