Re: Mark a single row?
[EMAIL PROTECTED] wrote: Hallo, I would like a single row in a table, and not more than one, to be used as a preferred value in another application. Is this possible, and, if yes, how? add a column 'preferred', tinyint(1) NOT NULL. To change the preferred value: START TRANSACTION UPDATE table SET preferred=0 UPDATE table SET preferred=1 WHERE column_id=1234 COMMIT -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ If you find my advice useful, please consider donating to a poor student! You can choose whatever amount you think my advice was worth to you. http://tinyurl.com/7oa5s -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Mark a single row?
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) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Mark a single row?
[EMAIL PROTECTED] 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 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Mark a single row?
Hallo Michael, Op 29 Aug 05 schreef Michael Stassen aan [EMAIL PROTECTED]: 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. MS It's hard to say without knowing just what you mean by used as a MS preferred value in another application, but I suspect that adding a MS whole column for this may not the best way to go. You'd be storing a MS lot of 0s just to keep one 1. The simplest solution may be to code the MS preferred row's id in your app. Your instinct to keep this value in the MS db is probably a better idea, however, especially if the preferred id MS could ever change. It won't change very often, but there certainly is a chance. That's why I decided to keep it in the database somehow, rather than hard-coding it. Also, this way the users can change it without having to mess with the code. The amount of 0s would not be more than about 40, so not a big disaster. MS An alternative to adding a column would be to add a table. MS Something like: MSCREATE TABLE pref_value (pref_id INT); MSINSERT INTO pref_value (pref_id) VALUES (id_of_preferred_row); But this method is much more elegant. I wonder why I couldn't think of it myself... Thank you very much! Groetjes, Hans. --- GoldED+/LNX 1.1.5/050823 * Origin: The Wizard is using MBSE/Linux (2:280/1018) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]