SQLite Getting only last record not all the Records

后端 未结 3 1878
臣服心动
臣服心动 2020-12-20 11:05

I have total 4 records in ecare table, where 2 records status is sent = 1, and other 2 records status is

3条回答
  •  醉话见心
    2020-12-20 11:21

    I have tried to re-create your database, is this right, what is the problem, seems to work.

    CREATE TABLE ecare (_id INTEGER PRIMARY KEY,h_id  INTEGER ,no  INTEGER);
    CREATE TABLE pweb (_id INTEGER PRIMARY KEY,h_id  INTEGER ,sent  INTEGER);
    sqlite> insert into ecare values(1, 10,1);
    sqlite> insert into ecare values(2, 20,2);
    sqlite> insert into ecare values(3, 30,3);
    sqlite> insert into ecare values(4, 40,4);
    sqlite>
    sqlite> insert into pweb values(1, 10,1);
    sqlite> insert into pweb values(2, 20,1);
    sqlite> insert into pweb values(3, 30,0);
    sqlite> insert into pweb values(4, 40,0);
    sqlite> select * from ecare;
    1|10|1
    2|20|2
    3|30|3
    4|40|4
    sqlite> select * from pweb;
    1|10|1
    2|20|1
    3|30|0
    4|40|0
    sqlite> SELECT p.sent,e.*, e.no _id from ecare e LEFT JOIN pweb p ON e.h_id=p.h_id WHERE p.sent = '0';
    0|3|30|3|3
    0|4|40|4|4
    sqlite>
    

提交回复
热议问题