Ah.
That's done with a "one to many relationship", where you have two tables
linked by a "foreign key".
This is a fundamental topic with SQL databases, Google should find
plenty of articles.
For example, this:
http://www.databaseprimer.com/relationship_1tox.html
Or this:
http://www.sqlite.org/foreignkeys.html
-- Kostya
12.11.2010 13:52, pramod.deore пишет:
Hi, Kostya Thanks. But I think it only override older value. what I
want is
If suppose I have
roomid:101
roomName:Hall
switchid:202
switchName:AC
Now if suppose I insert a record as(101,Hall,203, Light)
then record is added as
roomid:101
roomName:Hall
switchid:202,203
switchName:AC,Light.
I hope you understand what I am trying to say.
On Nov 12, 3:37 pm, Kostya Vasilyev<[email protected]> wrote:
If a record (row) already exists, you need to perform an update, not insert.
Before:
roomid: 1001
roomname: Scheherezade's bedroom
switchid, switchname: null
Update:
UPDATE tablename
SET switchid = 512, switchname = 'blahblah'
WHERE roomid = 1001
After:
roomid: 1001
roomname: Scheherezade's bedroom
switchid: 512
switchname: blahblah
You can use SQLiteDatbase.update for this:
http://developer.android.com/reference/android/database/sqlite/SQLite...,
android.content.ContentValues, java.lang.String, java.lang.String[])
-- Kostya
12.11.2010 13:21, pramod.deore пишет:
Hi all,
I have a table which has four columns (roomid primary key,
roomaname, switchid, and switchname). Now if I tried to insert a
record in this table then if roomid is not exist in the table then
record is added successfully. (And it is obvious ).
But what I want is if suppose primary key is exist already and
I tried to insert the record then last two columns values (i.e
switchid and switchname) is added to that record.
I think it is not possible. But still want to take experts
opinion.
Thanks
--
Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com
--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en