PostgreSQL Like

PostgreSQL Like

The PostgreSQL LIKE is used to return rows if the operand matches a pattern in a select.

Like syntax

SELECT * FROM table_name WHERE column_name LIKE pattern;

Like example

Goods table

idgood_typenamedescriptionpriceinsert_date
1ACar_1Car 1 description1002018-07-21 08:45:57.311809
2ACar_2Car 2 description2002018-07-21 08:45:57.311809
3ACar_3Car 3 description1002018-07-21 08:45:57.311809
4BBoat_4Boat 4 description5002018-07-21 08:45:57.311809
5BBoat_5Boat 5 description3002018-07-21 08:45:57.311809
6CTrain_1Train 123 description8002018-07-21 08:45:57.311809
select * from goods where name LIKE '%Boat%';

Result

idgood_typenamedescriptionpriceinsert_date
4BBoat_4Boat 4 description5002018-07-21 08:45:57.311809
5BBoat_5Boat 5 description3002018-07-21 08:45:57.311809
select * from goods where name LIKE 'Tra%';

Result

idgood_typenamedescriptionpriceinsert_date
6CTrain_1Train 123 description8002018-07-21 08:45:57.311809
select * from goods where good_type LIKE 'C';

Result

idgood_typenamedescriptionpriceinsert_date
6CTrain_1Train 123 description8002018-07-21 08:45:57.311809