views:

119

answers:

1

hii 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

+1  A: 

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 = ?
Nick U