Page 244 - Open Soource Technologies 304.indd
P. 244

Unit 14: Connecting to MySQL with PHP



                                                                                                  Notes




















            TO modify existing records, use UPDATE which has this form:
            UPDATE table_name SET which columns to change WHERE  which records to update.

            Here also the WHERE clause is optional, if you don’t specify one, every records in the table is
            updated.
            i.e., UPDATE table_name SET which columns to change

            for example you can change the specialization of a student whose roll number is 20, to etc.
            from cse.
            The following query fulfills the above change:

            mysql>UPDATE student SET specialization=”etc” where roll_no=”20”;

            After the execution of above query the contents of the table becomes:





















            14.2.10 Altering the Structure of Tables

            Using ALTER statement you can add  fields to a existing table.
            The general form of ALTER statement is:

            ALTER TABLE table_name ADD (column specs);

            Suppose you want to add another field as marks to the student table for storing students mark.
            Then the query becomes



                                             LOVELY PROFESSIONAL UNIVERSITY                                   239
   239   240   241   242   243   244   245   246   247   248   249