List:General Discussion« Previous MessageNext Message »
From:Michael Stassen Date:August 29 2005 6:43pm
Subject:Re: Mark a single row?
View as plain text  
lists.mysql-users@stripped wrote:
> Hallo Jasper,
> 
> Op 29 Aug 05 schreef Jasper Bryant-Greene aan mysql:
> 
>  >> I would like a single row in a table, and not more than one, to be
>  >> used as a preferred value in another application.
>  JBG> add a column 'preferred', tinyint(1) NOT NULL.
> 
> Thank you!
> 
> Groetjes,
> 
>            Hans.
> 
> --- GoldED+/LNX 1.1.5/050823
>  * Origin: The Wizard is using MBSE/Linux (2:280/1018)

It's hard to say without knowing just what you mean by "used as a preferred 
value in another application", but I suspect that adding a whole column for 
this may not the best way to go.  You'd be storing a lot of 0s just to keep 
one 1.  The simplest solution may be to code the preferred row's id in your 
app.  Your instinct to keep this value in the db is probably a better idea, 
however, especially if the preferred id could ever change.  An alternative 
to adding a column would be to add a table.  Something like:

   CREATE TABLE pref_value (pref_id INT);
   INSERT INTO pref_value (pref_id) VALUES (id_of_preferred_row);

You could then look up the preferred id from the pref_value table and then 
use it, or simply join the pref_value table to your existing table.

Michael

Thread
Mark a single row?lists.mysql-users29 Aug
  • Re: Mark a single row?Jasper Bryant-Greene29 Aug
Re: Mark a single row?lists.mysql-users29 Aug
  • Re: Mark a single row?Michael Stassen29 Aug
Re: Mark a single row?lists.mysql-users29 Aug