So I’m trying to do “my own” version of phpMyAdmin in the sense that I’m trying to do a bunch of general operations to tables.
Right now, I’m stuck at the ‘edit a row’ operation. Is there a command to edit the last selected row that I can use? Is there something that would let me do something along the lines of
update t set <blah blah> where (select * from t limit 0,1);
I ask because I can’t think of any other unique characteristics that my rows have as some primary keys are combinations of two foreign keys.
Thanks!
While you’re probably expecting an answer along these lines, I’ll step up and say it anyway: you should reconsider your database structure.
Combining two foreign keys together into a single primary key (alternatively, multiple primary keys) is a great way to force yourself into corners. You’ll have to write a lot of custom code that will be unique to your database, which others will have a difficult time understanding, and therefore it’ll be difficult to get help. It’ll also become difficult to debug your own code, since you’ll have problems returning to this non-standard code in the future when your project has grown.
Ideally, you should have a unique index on those two foreign keys, but have a single primary key that’s automatically generated. You can use the primary key for operations like what you’re suggesting, but also have fast lookup times on the foreign keys because of the index.