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!

Recommended Answers

All 4 Replies

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.

Maybe I missed the picture ...

You want to insert into table albums ...

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

Maybe?

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

yep, the UPDATE statement was it. Thanks a lot!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.