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

Unit 14: Connecting to MySQL with PHP



            The load data statement acts as a bulk loader that reads data from a file.            Notes
            Syntax is:

            mysql>LOAD DATA LOCAL INFILE filename INTO TABLE table_name;


                      By default, the load data statement assumes that column values are separated
                      by tabs and that lines end with new lines. It also assumes that the values are
                      present in the that columns are stored in the table. “filename” should present
                      in the user home directory.


            Now you can insert some data into the student table using the above described INSERT
            statement.

            mysql>INSERT INTO student VALUES(‘11’,’Subhransu Patra’,’cse’,’1983-6-3’);
            mysql>INSERT INTO student(roll_no,name,specialization) VALUES(‘12’,’Sudhansu Patra’,’etc’);
            mysql>INSERT INTO student SET name=’Suvransu’,specialization=’ee’;

            mysql>INSERT INTO student VALUES(‘14’,’Jonny’,’etc’,’1982-6-2’);
            mysql>INSERT INTO student VALUES(‘15’,’Missy’,’ee’,’1981-5-4’);

            mysql>INSERT INTO student VALUES(‘16’,’Jenny’,’cse’,’1982-5-7’);
            mysql>INSERT INTO student VALUES(‘17’,’Billy’,’etc’,’1984-5-4’);
            mysql>INSERT INTO student VALUES(‘18’,’Kyle’,’cse’,’1983-7-6’);

            mysql>INSERT INTO student VALUES(‘19’,’Nathan’,’ee’,’1982-2-5’);
            mysql>INSERT INTO student VALUES(‘20’,’Abby’,’cse’,’1984-9-8’);

            14.2.8 Retrieving Information from a Table
            The SELECT statement allows you to retrieve and display information from your table.

            The general form of SELECT is:

            mysql>SELECT <fields-to-select>
            FROM <table or tables>


























                                             LOVELY PROFESSIONAL UNIVERSITY                                   237
   237   238   239   240   241   242   243   244   245   246   247