I want to select records that begin same as first but without it. First one could change depending on user's choice so solution must be 'dynamic'. I tried putting substring containing first three chracters of first record to NOT LIKE () function but it doesn't work, got messege that 'like (text) doesn't exist'. Could I get help to resolve this problem? Thanks in advance.
Edit: I'm using PostgreSQL 9.4.4 and I no longer get error, instead of this my query that is posted below returns entire table.
select * from codes where code not like substring((select code from codes where id = 1) from 1 for 3);
Table:
+--------+-----------+
|code_id |code |
|[PK]int |varchar(10)|
+--------+-----------+
|1 |00011111 |
|2 |11111111 |
|3 |11122222 |
|4 |00022222 |
|5 |00033333 |
+--------+-----------+
Result:
+--------+-----------+
|code_id |code |
|[PK]int |varchar(10)|
+--------+-----------+
|4 |00022222 |
|5 |00033333 |
+--------+-----------+