Getting Data from multiple tables SQLite

前端 未结 2 1105
甜味超标
甜味超标 2021-01-29 02:21

I have an android application that has 2 tables, one table stores posts and the other table stores images of the posts incase it has an image, changes are not all posts will hav

2条回答
  •  逝去的感伤
    2021-01-29 02:54

    Try using Left join and that will result all entries from left table and matched entries from right table.

    SELECT posttable.postid,posttable.post,posttable.postdescription, imagetable.imageid,imagetable.fkpostid,imagetable.imagepath
    FROM posttable
    LEFT JOIN imagetable
    ON posttable.postid=imagetable.fkpostid
    ORDER BY posttable.postid; 
    

    Code should look like that.

    http://www.w3schools.com/sql/sql_join_left.asp

提交回复
热议问题