mySQL help
Author |
Message |
2facetious
|
Posted: Thu Jul 12, 2007 10:52 am Post subject: 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 |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Thu Jul 12, 2007 11:12 am Post subject: 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. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Dan
|
Posted: Thu Jul 12, 2007 11:17 am Post subject: RE:mySQL help |
|
|
What is the primary key currently defined as or is there even one? |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
|
2facetious
|
Posted: Thu Jul 12, 2007 11:41 am Post subject: 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
|
Posted: Thu Jul 12, 2007 11:43 am Post subject: RE:mySQL help |
|
|
IF I add one, rather. lol |
|
|
|
|
|
Amailer
|
Posted: Thu Jul 12, 2007 12:26 pm Post subject: RE:mySQL help |
|
|
Yeah, you can always add your own unique id column to solve the issue (ALTER TABLE) |
|
|
|
|
|
Tony
|
Posted: Thu Jul 12, 2007 12:48 pm Post subject: Re: RE:mySQL help |
|
|
2facetious @ Thu Jul 12, 2007 11:41 am wrote: 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. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
octopi
|
Posted: Thu Jul 12, 2007 2:04 pm Post subject: 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? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
|
|