Tengo una tabla en SQLite3 (https://sqliteonline.com/) Y me piden los siguiente:
-- Escriba una consulta que retorne los campos K0 y c16 para los registros de la tabla tbl1 para los que la columna c16 empieza por la misma letra de la columna K0.
El problema es que no sabría como hacer el LIKE usando el valor de otro campo.
El codigo que tengo es el siguiente, pero no me funciona
SELECT K0, c16
from tbl1
where c16 LIKE '$K0%'
El código SQL de la tabla es el siguiente:
CREATE TABLE tbl1 (
K0 CHAR(1),
K1 INT,
c12 FLOAT,
c13 INT,
c14 DATE,
c15 FLOAT,
c16 CHAR(4)
);
INSERT INTO tbl1 VALUES
('E',1,273.08,600,'2016-12-31',0.21,'BDGD'),
('D',2,756.37,500,'2019-02-28',0.37,'BCCC'),
('E',3,305.43,100,'2017-05-21',0.21,'BAED'),
('D',4,662.69,800,'2017-03-26',0.23,'BGDD'),
('C',5,822.81,100,'2017-11-17',0.35,'GGFC'),
('A',6,391.42,300,'2018-05-15',0.22,'BFGB'),
('C',7,755.27,800,'2018-07-04',0.47,'GCDB'),
('E',8,302.86,700,'2016-12-22',0.14,'DFCC'),
('C',9,267.42,200,'2018-04-18',0.10,'DGCE'),
('A',10,816.51,600,'2019-04-25',0.40,'DAGC'),
('C',11,346.64,900,'2017-04-18',0.15,'FBBC'),
('B',12,999.72,800,'2016-11-09',0.26,'FCGD'),
('C',13,712.61,400,'2017-10-23',0.31,'EDDA'),
('E',14,832.44,800,'2016-11-22',0.39,'EGFD'),
('C',15,370.58,900,'2016-10-01',0.11,'GCDD'),
('B',16,283.40,600,'2019-04-11',0.14,'BDEE'),
('E',17,692.93,200,'2018-03-25',0.25,'BGGA'),
('A',18,142.99,100,'2017-02-12',0.48,'GGFD'),
('C',19,570.43,400,'2019-04-12',0.48,'FBEE'),
('A',20,938.16,300,'2016-09-12',0.19,'BECB'),
('B',21,409.34,400,'2019-04-29',0.23,'GFAE'),
('E',22,118.77,900,'2016-10-29',0.32,'GEFE'),
('E',23,325.15,200,'2019-04-21',0.19,'FBGC'),
('C',24,482.32,300,'2019-05-03',0.11,'CCCE'),
('E',25,600.90,700,'2018-11-07',0.36,'BBBA'),
('A',26,456.47,400,'2018-01-28',0.11,'FGED'),
('E',27,720.90,800,'2017-01-16',0.12,'FBGD'),
('B',28,326.45,700,'2017-07-27',0.36,'AGAA'),
('D',29,317.77,200,'2017-02-27',0.47,'GCEA'),
('A',30,135.80,900,'2017-01-26',0.23,'EGAB');