
-----------------------------------
2facetious
Thu Jul 12, 2007 10:52 am

mySQL help
-----------------------------------
I'm wondering if anyone can help me with this. I've tried google because they usually have the answer to everything, but no help there. I'm in the middle of a job and I'm using a mySQL database that was created a long time ago, prior to my involvement. My problem is that whoever created the database didn't use an id column. I want to know if I can access rows by number instead of id. I could add the id, but that causes a whole bunch of other problems so accessing by row number would be the best solution if it can be done. I appreciate any help that you guys can give me. Thanks!

Lesley

-----------------------------------
Tony
Thu Jul 12, 2007 11:12 am

RE:mySQL help
-----------------------------------
Wouldn't line numbers be unreliable? The set could be returned in a different order unless you're sorting by a primary key, in which case you should probably be using that instead.

-----------------------------------
Dan
Thu Jul 12, 2007 11:17 am

RE:mySQL help
-----------------------------------
What is the primary key currently defined as or is there even one?

-----------------------------------
2facetious
Thu Jul 12, 2007 11:41 am

RE:mySQL help
-----------------------------------
Yeah, I know what you mean. But like I said, there is no unique id column (primary key). If I had one, I have to recompile, etc. I just wondered if there was an easier way. Thanks for your help.

-----------------------------------
2facetious
Thu Jul 12, 2007 11:43 am

RE:mySQL help
-----------------------------------
IF I add one, rather. lol

-----------------------------------
Amailer
Thu Jul 12, 2007 12:26 pm

RE:mySQL help
-----------------------------------
Yeah, you can always add your own unique id column to solve the issue (ALTER TABLE)

-----------------------------------
Tony
Thu Jul 12, 2007 12:48 pm

Re: RE:mySQL help
-----------------------------------
But like I said, there is no unique id column (primary key).
Primary key could be made up of more than one column. If there is no primary key, then "row number" is as effective as pulling out records at random.

-----------------------------------
octopi
Thu Jul 12, 2007 2:04 pm

RE:mySQL help
-----------------------------------
If there is a unique column, mysql will use that as the primary key, I find it difficult to believe that someone has created a table without a primary key.  Are you positive that there isn't a unique or primary key on the table? ...How in the past were they able to delete/update individual records?
