0

Hello everyone!
I am writing a music database, and I need to insert into album table the path to its cover. However, not every album has a cover in its directory, so I've made an algorithm that only gets the albumID that has a cover. My question is - how can I insert value into one column in a row with a specific ID (or name)? I have tried this -

"insert into albums (cover_path) values ('%s') WHERE albumID=%d"

but it sais that theres an error at WHERE. How can I do this? I am using sqlite3 and C++. Thanks!

2
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by linux0id
0

It sounds like you need to UPDATE rather than insert. Insert is used when the row doesn't exist at all. Update is used when you want to change the value of one or more columns in an existing row.

UPDATE albums 
SET cover_path = [I]Your_Path[/I]
WHERE albumID = [I]Your_Album_Id[/I]

Hope that helps.

0

Maybe I missed the picture ...

You want to insert into table albums ...

insert into albums (albumID, cover_path) values ('%s', %d)

Maybe?

0

UPDATE is what I think I need. I will try it out tonight and see what happens. Thanks

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.