Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 14 of 14
  1. #1
    Banned
    Join Date
    Sep 2011
    Posts
    140
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Updating field data

    I have this:
    +------+---------------+------------+
    | id | primarycolour | pricerange |
    +------+---------------+------------+
    | 1 | black | 1 |
    | 2 | brown | 2 |
    +------+---------------+------------+
    ... and I want to change the pricerange of "id 2" from 2 to 1.

    I tried this, but it didn't work:
    Code:
    UPDATE products(pricerange) where id=2 VALUES(1);
    Does anyone know how it can be done?

  • #2
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,285
    Thanks
    4
    Thanked 201 Times in 198 Posts
    Code:
    UPDATE `products` SET `pricerange` = 1 WHERE `id` = 2
    Dave .... HostMonster for all of your hosting needs

  • Users who have thanked djm0219 for this post:

    Democrazy (09-12-2011)

  • #3
    Banned
    Join Date
    Sep 2011
    Posts
    140
    Thanks
    17
    Thanked 0 Times in 0 Posts
    Hi Dave,

    I tried the command you suggested, and got this error message:
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''products' set 'pricerange' = 1 where 'id' = 2' at line 1

  • #4
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,285
    Thanks
    4
    Thanked 201 Times in 198 Posts
    You didn't copy what I posted apparently. You used single quotes around the table and field names instead of back ticks as shown in my post. HUGE difference between them.
    Dave .... HostMonster for all of your hosting needs

  • #5
    Banned
    Join Date
    Sep 2011
    Posts
    140
    Thanks
    17
    Thanked 0 Times in 0 Posts
    Your absolutely right about that. Sorry about that I've never seen the ` used before outside of computing gaming and in MS-DOS and got confused. Thanks for your help, the code worked.

  • #6
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,285
    Thanks
    4
    Thanked 201 Times in 198 Posts
    I might suggest that you download a PDF copy of the MySQL reference manual which will help you with questions like this.
    Dave .... HostMonster for all of your hosting needs

  • #7
    Banned
    Join Date
    Sep 2011
    Posts
    140
    Thanks
    17
    Thanked 0 Times in 0 Posts
    I have read the HTML reference manual just pasted the tutorial, then after it made no sense to me.
    The problem with MySQL's official documentation after the tutorial, is that it stops speaking in 'English' and talks in syntaxes only.

    In regards to the reference manual, when I goto the 'DELETE' page, it speaks in syntaxes only, if I don't know what these syntaxes are or how they should be used, how am I suppose to know what they mean? By reading the manual? The manual is over 3000 pages long and hoeplessly indexed.

    I am writing my own user friendly user manual at the moment that talks in street talk. I will publish it to the community when its allot more populated.
    Last edited by Democrazy; 09-12-2011 at 09:21 AM.

  • #8
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,285
    Thanks
    4
    Thanked 201 Times in 198 Posts
    No offense but you need to be able to read and understand syntax diagrams. You'll find them in just about anything "web related" you may use/need. Early on in the manual is an explanation of syntax diagrams and how to read/use them.
    Dave .... HostMonster for all of your hosting needs

  • #9
    Banned
    Join Date
    Sep 2011
    Posts
    140
    Thanks
    17
    Thanked 0 Times in 0 Posts
    Ah! Yeah, sorry.. what I meant was I can understand syntaxes, but I need to know what the syntax does, and there are many syntaxes used in diagrams I am unfamiliar with.

    you mentioned an index page within the manual that describes what each syntax does. Where is that?

    Here is a perfect example of what I am after, but for MySQL:
    http://www.w3.org/TR/1999/REC-html40.../elements.html

  • #10
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,285
    Thanks
    4
    Thanked 201 Times in 198 Posts
    The standard index has essentially that and there are indexes for operators and an index for statement syntax too (plus others). You'd be hard pressed to NOT find what you're looking for really.
    Dave .... HostMonster for all of your hosting needs

  • #11
    Banned
    Join Date
    Sep 2011
    Posts
    140
    Thanks
    17
    Thanked 0 Times in 0 Posts
    To give you an example, here is the delete page:

    http://dev.mysql.com/doc/refman/5.5/en/delete.html

    "DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name"

    What is LOW_PRIORITY QUICK and IGNORE??? See, this is what I do not understand, and the page does not tell you what they are... and the page is so long... All I want to do is delete something. I shouldn't have to read pages just to try and figure out how.

    Here is an extract on deleting out of my MySQL street-talk manual I am making for the community.. its short because I haven't finished it yet, but it gives you an example of what I mean:

    Delete field data:
    DELETE from (database).(table) where (field)="(data)";

    Delete table:
    DROP tables (table);
    Self-explanitry and nice and simple!
    Last edited by Democrazy; 09-12-2011 at 12:42 PM.

  • #12
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,285
    Thanks
    4
    Thanked 201 Times in 198 Posts
    Quote Originally Posted by Democrazy View Post
    Self-explanitry and nice and simple!
    But you are missing all of the options and possibilities. If it were as simple as you have it that is the way it would be in the manual. But it isn't.

    And if you had gone down about 1 web page worth on the page on the MySQL site you would have seen the explanation of what Quick, Low_Priority and Ignore are for.
    Dave .... HostMonster for all of your hosting needs

  • #13
    Banned
    Join Date
    Sep 2011
    Posts
    140
    Thanks
    17
    Thanked 0 Times in 0 Posts
    Yes, but I shouldn't have to figure out what all the optional commands are when I am not even using them.

    The official manual should start by presenting the functions use at a basic level, and then move on to explain using it in a more advanced way.
    At the moment, it explains everything in one go, meaning in order for someone to learn how to use it at basic, they have to understand the most advanced functions of it. Thats very faith-braking, frustrating and totally time wasting, where as my way describes the action in English and gives an individual explination of the function in each of its uses.

    You want to do this:
    DONE LIKE THIS

    You want to do that:
    DONE LIKE THAT

    Yes, the ways I have in my manual at the moment are basic, but thats because I haven't come to using advanced syntaxes myself, yet.
    With my stree-talk manual, people get an explination in street-talk, and a straight out way on how to use the command. This is very user-friendly.

    I cannot stress how important Documentation is with computers. This is one major reason why Linux failed as a desktop OS - lack of user-friendly documentation.

    I am trying my best to help the beginner group of people in the MySQL community like myself by addressing learning issues I face with the street-talk manual I am writing, so the next generation of noobs won't have to go through the hell I am going through.
    Last edited by Democrazy; 09-12-2011 at 01:44 PM.

  • #14
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Quote Originally Posted by Democrazy View Post
    Yes, but I shouldn't have to figure out what all the optional commands are when I am not even using them.
    STRONG disagreement.

    You may not need to memorize them, but you need to be aware they exist.

    The day may well come when you will need them.

    It doesn't take *THAT* long to read the description of, for example, "LOW_PRIORITY" and realize that you don't need it now. But if you ever had a situation where you had some important queries to run at the same time as a LOW_PRIORITY one, you'd know it was there.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •