By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table obj_table (
object_id INT,
field_name VARCHAR(12),
value VARCHAR(12)
);
insert into obj_table values (1, 'latitude', '23.00001');
insert into obj_table values (1, 'longitude', '45.23445');
insert into obj_table values (1, 'category', 'office');
insert into obj_table values (2, 'latitude', '13.21451');
insert into obj_table values (2, 'longitude', '25.34355');
insert into obj_table values (2, 'category', 'center');
select * from obj_table;
object_id | field_name | value |
---|---|---|
1 | latitude | 23.00001 |
1 | longitude | 45.23445 |
1 | category | office |
2 | latitude | 13.21451 |
2 | longitude | 25.34355 |
2 | category | center |
select
lng.object_id,
ltd.value as latitude,
lng.value as longitude
from obj_table lng, obj_table ltd
where lng.field_name = 'longitude'
and ltd.field_name = 'latitude'
and lng.object_id = ltd.object_id
;
object_id | latitude | longitude |
---|---|---|
1 | 23.00001 | 45.23445 |
2 | 13.21451 | 25.34355 |