Web Analytics Made Easy -
StatCounter Updating field data - CodingForum

Announcement

Collapse
No announcement yet.

Updating field data

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    Code:
    UPDATE `products` SET `pricerange` = 1 WHERE `id` = 2
    Dave .... HostMonster for all of your hosting needs

    Comment


    • #3
      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

      Comment


      • #4
        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

        Comment


        • #5
          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.

          Comment


          • #6
            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

            Comment


            • #7
              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; Sep 12, 2011, 04:21 AM.

              Comment


              • #8
                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

                Comment


                • #9
                  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:

                  Comment


                  • #10
                    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

                    Comment


                    • #11
                      To give you an example, here is the delete page:



                      "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; Sep 12, 2011, 07:42 AM.

                      Comment


                      • #12
                        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

                        Comment


                        • #13
                          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; Sep 12, 2011, 08:44 AM.

                          Comment


                          • #14
                            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.
                            Be yourself. No one else is as qualified.

                            Comment

                            Working...
                            X
                            😀
                            🥰
                            🤢
                            😎
                            😡
                            👍
                            👎