HomeОбразованиеRelated VideosMore From: PhpSword

Learn How to Add Data Rows in a Table using SQL

13 ratings | 6343 views
Learn about using INSERT INTO SQL statements. The INSERT INTO statement is used to insert or add new data rows in a table. There are two methods to INSERT the data rows in a table. In First method, column names are not specified and the values are given in a bracket separated by a comma. In this method the values for each column must be specified and the values should be provided sequentially by columns. "INSERT INTO tablename VALUES (value1, value2, value3);" In second method, the column names are given in first bracket and the values are given in another bracket. In this method we can INSERT values to only selected column names. This is the convenient way to store the data rows, as we can see which value is going to be stored in which column. "INSERT INTO tablename (column1, column2, column3) VALUES (value1, value2, value3);" While using INSERT INTO statement the string values must be wrapped in single quotes, while wrapping numeric values in quotes is optional or not required. I'll select the "school" database, "USE school;" I'll run a simple SQL statement to display all the data rows in teachers table using SQL statement, "SELECT * FROM teachers;" Add new data row using SQL statement, "INSERT INTO teachers VALUES (NULL, 'Peter Brown', 1234509876);" In this INSERT INTO SQL statement, column names are not specified. Since, the teacherid column is auto increment that is it will automatically add the next number for the data row, we provided the 'NULL' value means no value for that column. Press enter to execute the SQL statement. If you see the message, "Query OK, 1 row affected", it means the data row was successfully inserted to the table. Check out the whole playlist of SQL Tutorials or Individual video from the following links, SQL Tutorial for Beginners. Introduction to SQL Basics https://www.youtube.com/playlist?list=PLhwzZMYRiUErXXX0Ryud2R7RjesCEdTqi 1.Learn What is SQL? Introduction to SQL https://www.youtube.com/watch?v=ox6zUOKascs 2.Learn How to Install MySQL Database Server on Windows Operating System https://www.youtube.com/watch?v=vtnoWaydkEU 3.Learn What is Database? How to Create and Show Databases using SQL https://www.youtube.com/watch?v=-yJgWq6K_U8 4.Learn How to Select and Use Existing Database using SQL https://www.youtube.com/watch?v=QMViQ38SPxc 5.Learn How to Delete or Remove Database using SQL https://www.youtube.com/watch?v=wjEOZKvfH4c 6.Learn What is Database Table? How to Create a Database Table using SQL? https://www.youtube.com/watch?v=8SvtNIfzC4o 7.Learn How to Modify or Update Database Table using SQL https://www.youtube.com/watch?v=1he5oZzG33o 8.Learn How to Delete or Remove Database Table using SQL https://www.youtube.com/watch?v=JD87WvBist0 9.Learn How to Add Data Rows in a Table using SQL https://www.youtube.com/watch?v=UB-bQxAQbWg 10.Learn How to Use INSERT INTO SELECT Statement in SQL https://www.youtube.com/watch?v=U4ApxHF4R1g 11.Learn How to Update Data Rows using Update Statement in SQL https://www.youtube.com/watch?v=lE1BmNbFJdo 12.Learn How to Delete Data Rows using Delete Statement in SQL https://www.youtube.com/watch?v=1ViqX1tFgYM Subscribe to my channel: https://www.youtube.com/channel/UCvrq9OowoORTV5Gs_jpADhw
Html code for embedding videos on your blog
Text Comments (6)
Beso moon (13 days ago)
How to Insert Into Table from table another without duplication in sql
PhpSword (13 days ago)
Hello Beso moon, checkout the following link, where I've explained how to insert data from one table to another table. In order to avoid duplicate values, you can apply unique constraints to specific columns. https://www.youtube.com/watch?v=U4ApxHF4R1g
santosh modadugu (2 months ago)
How to add table rows and cloumns, in earlier video you showed only fields inside box, how to add headdings and other fields pls explain..
PhpSword (2 months ago)
Hello Santosh, Sorry for the late response, I was busy this weekend. You are talking about creating table with respected columns. I already have included that video, here is the link, https://www.youtube.com/watch?v=8SvtNIfzC4o Let me know if you have any doubts.
ThatsRight (2 years ago)
Adding data into tables can also be done with phpmyadmin, then why should we use the CMD for that?
PhpSword (2 years ago)
The tutorial is mainly focused on working with MySQL command line client therefore I used SQL statement instead of phpmyadmin.

Would you like to comment?

Join YouTube for a free account, or sign in if you are already a member.