quote: Is it possible to use any other unique field to determine which one I want?
Yes.
quote: Do I need to make the field a Primary or Unique or Indexed field or something?
No, but correctly indexing tables improves performances.
I can't remember your database structure (if you shared it), but you would make id your Primary key, and code could be either Indexed or Unique Indexed.
(Afaik, Unique is a constraint that prevents you INSERTing non-distinct code values, but doesn't affect SELECTing.)
Depending on other queries, you may benefit from adding other indexes/indices also - missing or incorrect indexes is a common cause of slow performance in database [web] apps.
quote: Coding that is fine, but it doesn't pull the record out. I'm assuming it's because it's not indexed?
Nope - just to be clear - indexes affect how queries run, but not what they return. (Analogy: The index in the back of a book doesn't change what a book contains, but can speed up your searching for something.)
If you're doing the parameterized queries that Matt suggested before, you will need to use %s for this instead of %d, as the latter means decimal integer and your code looks to be a string. |