开发者

sqlite join query

开发者 https://www.devze.com 2022-12-14 22:01 出处:网络
i am new to iPhone, I am using sqlite3 as my database. There are two tables in database as FriendInfo and ItemInfo. FriendInfo contain FriendId and some other field relative to friend info which are

i am new to iPhone,

I am using sqlite3 as my database. There are two tables in database as FriendInfo and ItemInfo. FriendInfo contain FriendId and some other field relative to friend info which are quine in this table and ItemInfo contain the ItemId as primary key and friend Id as Foreign Key, i want to execute the join query which select values from FriendInfo table based on friendid and also select item from ItemInfo based on same friendid .

Currently i am using开发者_如何学运维 two different this query execute in one method "Select" query for each table like this

Select name,birthday,note,pic from friendinfo where friendid=?

and this second query in another method

Select itemname,price,storename from iteminfo where friendid=?

I want a single join query to perform the operation ......... if please posssible suggest me the code how to implement join query in iPhone using sqlite3 as database


This query should work:

select fi.name, fi.birthday, fi.note, fi.pic, ii.itemname, ii.price, ii.storename
from friendinfo fi
inner join iteminfo ii on ii.friendid = fi.friendid
where fi.friendid = ?
0

精彩评论

暂无评论...
验证码 换一张
取 消