Trending November 2023 # Mysql Insert Into Query: How To Add Row In Table (Example) # Suggested December 2023 # Top 19 Popular

You are reading the article Mysql Insert Into Query: How To Add Row In Table (Example) updated in November 2023 on the website We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested December 2023 Mysql Insert Into Query: How To Add Row In Table (Example)


INSERT INTO is used to store data in the tables. The INSERT command creates a new row in the table to store data. The data is usually supplied by application programs that run on top of the database.

Basic syntax

Let’s look at the basic syntax of the INSERT INTO MySQL command:

INSERT INTO `table_name`(column_1,column_2,...) VALUES (value_1,value_2,...);


INSERT INTO `table_name` is the command that tells MySQL server to add a new row into a table named `table_name.`

(column_1,column_2,…) specifies the columns to be updated in the new MySQL row

VALUES (value_1,value_2,…) specifies the values to be added into the new row

When supplying the data values to be inserted into the new table, the following should be considered:

String data types – all the string values should be enclosed in single quotes.

Numeric data types- all numeric values should be supplied directly without enclosing them in single or double-quotes.

Date data types – enclose date values in single quotes in the format ‘YYYY-MM-DD’.


Suppose that we have the following list of new library members that need to be added to the database.

Full names Date of Birth gender Physical address Postal address Contact number Email Address

Leonard Hofstadter   Male Woodcrest   0845738767  

Sheldon Cooper   Male Woodcrest   0976736763  

Rajesh Koothrappali   Male Fairview   0938867763  

Leslie Winkle 14/02/1984 Male     0987636553  

Howard Wolowitz 24/08/1981 Male South Park P.O. Box 4563 0987786553 [email protected]

INSERT INTO `members` (`full_names`,`gender`,`physical_address`,`contact_number`) VALUES ('Leonard Hofstadter','Male','Woodcrest',0845738767);

Executing the above script drops the 0 from Leonard’s contact number. This is because the value will be treated as a numeric value, and the zero (0) at the beginning is dropped since it’s not significant.

To avoid such problems, the value must be enclosed in single quotes as shown below –

INSERT INTO `members` (`full_names`,`gender`,`physical_address`,`contact_number`) VALUES ('Sheldon Cooper','Male','Woodcrest', '0976736763');

Changing the order of the columns has no effect on the INSERT query in MySQL as long as the correct values have been mapped to the correct columns.

The query shown below demonstrates the above point.

INSERT INTO `members` (`contact_number`,`gender`,`full_names`,`physical_address`) VALUES ('0938867763','Male','Rajesh Koothrappali','Woodcrest');

The above queries skipped the date of birth column. By default, MySQL will insert NULL values in columns that are omitted in the INSERT query.

Let’s now insert the record for Leslie, which has the date of birth supplied. The date value should be enclosed in single quotes using the format ‘YYYY-MM-DD’.

INSERT INTO `members` (`full_names`,`date_of_birth`,`gender`,`physical_address`,`contact_number`) VALUES ('Leslie Winkle','1984-02-14','Male','Woodcrest', '0987636553');

All of the above queries specified the columns and mapped them to values in the MySQL insert statement. If we are supplying values for ALL the columns in the table, then we can omit the columns from the MySQL insert query.


INSERT INTO `members` VALUES (9,'Howard Wolowitz','Male','1981-08-24', 'SouthPark','P.O. Box 4563', '0987786553', 'lwolowitz[at]');

Let’s now use the SELECT statement to view all the rows in the member’s table.

SELECT * FROM `members`;

membership_ number full_ names gender date_of_ birth physical_address postal_ address contct_ number email

1 Janet Jones Female 21-07-1980 First Street Plot No 4 Private Bag 0759 253 542 [email protected]

2 Janet Smith Jones Female 23-06-1980 Melrose 123 NULL NULL

3 Robert Phil Male 12-07-1989 3rd Street 34 NULL 12345

4 Gloria Williams Female 14-02-1984 2nd Street 23 NULL NULL NULL

5 Leonard Hofstadter Male NULL Woodcrest NULL 845738767 NULL

6 Sheldon Cooper Male NULL Woodcrest NULL 0976736763 NULL

7 Rajesh Koothrappali Male NULL Woodcrest NULL 0938867763 NULL

8 Leslie Winkle Male 14-02-1984 Woodcrest NULL 0987636553 NULL

9 Howard Wolowitz Male 24-08-1981 SouthPark P.O. Box 4563 0987786553 [email protected]

Notice the contact number for Leonard Hofstadter has dropped the zero (0) from the contact number. The other contact numbers have not dropped the zero (0) at the beginning.

Inserting into a Table from another Table

The INSERT command can also be used to insert data into a table from another table. The basic syntax is as shown below.

INSERT INTO table_1 SELECT * FROM table_2;

Let’s now look at a practical example. We will create a dummy table for movie categories for demonstration purposes. We will call the new categories table categories_archive. The script shown below creates the table.

CREATE TABLE `categories_archive` ( `category_id` int(11) AUTO_INCREMENT, `category_name` varchar(150) DEFAULT NULL, `remarks` varchar(500) DEFAULT NULL, PRIMARY KEY (`category_id`) )

Execute the above script to create the table.

Let’s now insert all the rows from the categories table into the categories archive table. The script shown below helps us to achieve that.

INSERT INTO `categories_archive` SELECT * FROM `categories`;

Executing the above script inserts all the rows from the categories table into the categories archive table. Note the table structures will have to be the same for the script to work. A more robust script is one that maps the column names in the insert table to the ones in the table containing the data.

The query shown below demonstrates its usage.

INSERT INTO `categories_archive`(category_id,category_name,remarks) SELECT category_id,category_name,remarks FROM `categories`;

Executing the SELECT query

SELECT * FROM `categories_archive`

gives the following results shown below.

category_id category_name remarks

1 Comedy Movies with humour

2 Romantic Love stories

3 Epic Story acient movies

4 Horror NULL

5 Science Fiction NULL

6 Thriller NULL

7 Action NULL

8 Romantic Comedy NULL

9 Cartoons NULL

10 Cartoons NULL

PHP Example: Insert into MySQL Table

The mysqli_query function is used to execute SQL queries.

The SQL insert into table function can be used to execute the following query types:





It has the following syntax.



“mysqli_query(…)” is the function that executes the SQL queries.

“$query” is the SQL query to be executed

“$link_identifier” is optional, it can be used to pass in the server connection link

Example $servername = "localhost"; $username = "alex"; $password = "yPXuPT"; $dbname = "afmznf"; $conn = mysqli_connect($servername, $username, $password, $dbname); if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } if (mysqli_query($conn, $sql)) { } else { } } Summary

The INSERT command is used to add new data into a table. MySql will add a new row, once the command is executed.

The date and string values should be enclosed in single quotes.

The numeric values do not need to be enclosed in quotes.

The INSERT command can also be used to insert data from one table into another.

You're reading Mysql Insert Into Query: How To Add Row In Table (Example)

How To Add Header Row To A Pandas Dataframe?

Pandas is a super popular data handling and manipulation library in Python which is frequently used in data analysis and data pre-processing. The Pandas library features a powerful data structure called the Pandas dataframe, which is used to store any kind of two-dimensional data. In this article we will learn about various ways to add a header row (or simply column names) to a Pandas dataframe.

NOTE − The code in this article was tested on a jupyter notebook.

We will see how to add header rows in 5 different ways −

Adding header rows when creating a dataframe with a dictionary

Adding header rows when creating a dataframe with a list of lists

Adding header rows after creating the dataframe

Adding header rows when reading files from a CSV

Adding header rows using set_axis method

Let’s begin by importing Pandas

import pandas as pd Method 1: When creating a dataframe with a dictionary Example # Add header row while creating the dataframe through a dictionary data = {'course': ['Math', 'English', 'History', 'Science', 'Physics'], 'instructor': ['John Smith', 'Sarah Johnson', 'Mike Brown', 'Karen Lee', 'David Kim'], 'batch_size': [43, 25, 19, 51, 48] } df1 = pd.DataFrame(data) df1 Output course instructor batch_size 0 Math John Smith 43 1 English Sarah Johnson 25 2 History Mike Brown 19 3 Science Karen Lee 51 4 Physics David Kim 48 Method 2: When creating a dataframe with list of lists Example # Add header row while creating the dataframe through lists data = [['apple', 'red', 5], ['banana', 'yellow', 12]] columns = ['fruit', 'color', 'quantity'] df2 = pd.DataFrame(data, columns=columns) df2 Output fruit color quantity 0 apple red 5 1 banana yellow 12

In this method, we have a list of lists where each sub-list stores the information for the rows of the dataframe. We make a list of column names and pass it to the pd.DataFrame method while initializing the dataframe.

Method 3: After creating the dataframe Example # Add header row after creating the dataframe data = [['apple', 'red', 5], ['banana', 'yellow', 12]] columns = ['fruit', 'color', 'quantity'] df3 = pd.DataFrame(data) df3.columns = columns df3 Output fruit color quantity 0 apple red 5 1 banana yellow 12

In the code above we first initialize a dataframe without any header rows. Then we initialize a list of column names we want to use and use the pd.DataFrame.columns attribute to set the header rows of the already defined Pandas dataframe.

Method 4: When reading files from a CSV file Example

When trying to read a CSV file using Pandas, it automatically considers the first row as the column names. However it is likely there is no column name present in our dataset as shown in the example below. Let’s assume the dataset is stored as ‘course_data.csv’.

# Incorrect header row df4 = pd.read_csv('course_data.csv') df4 Output Math John Smith 43 0 English Sarah Johnson 25 1 History Mike Brown 19 2 Science Karen Lee 51 3 Physics David Kim 48

The output shows that Pandas is interpreting a data sample as the header row. To tackle this, we will specify the column names by passing a list of header row names through the ‘names’ argument.

Example # Add header row while reading files from CSV columns = ['course', 'instructor', 'batch_size'] df4 = pd.read_csv('course_data.csv', names=columns) df4 Output course instructor batch_size 0 Math John Smith 43 1 English Sarah Johnson 25 2 History Mike Brown 19 3 Science Karen Lee 51 4 Physics David Kim 48

As shown in the output above, Pandas is no longer reading the first data sample as a header row!

Method 5: Using set_axis method Example

We already saw how to add header rows to an existing dataframe in Method 2. Now we will achieve the same using the pd.DataFrame.set_axis method.

# Add row row after creating the dataframe using set_axis data = [['dog', 'brown', 4], ['cat', 'white', 4], ['chicken', 'white', 2]] df5 = pd.DataFrame(data) columns = ['animal', 'color', 'num_legs'] df5.set_axis(columns, axis=1, inplace=True) df5 Output animal color num_legs 0 dog brown 4 1 cat white 4 2 chicken white 2

Here first we initialize a dataframe without any header rows using the data above. Then we use the set_axis method to add the header rows. We pass axis=1 to specify that we are setting the column names. We also set the flag, ‘inplace’ to be True to do in-place.

NOTE − Setting axis = 0 would set row-names instead of column-names and may also throw errors since there are usually more rows than columns.


This article taught us how to add headers to dataframes in Pandas. We saw 5 different ways to do so which can be used in various different applications and projects.

Mysql Query To Display Databases Sorted By Creation Date?

| Database                  | | bothinnodbandmyisam       | | business                  | | commandline               | | customer_tracker_database | | customertracker           | | database1                 | | databasesample            | | demo                      | | education                 | | hb_student_tracker        | | hello                     | | information_schema        | | javadatabase2             | | javasampledatabase        | | mybusiness                | | mydatabase                | | mysql                     | | onetomanyrelationship     | | performance_schema        | | rdb                       | | sample                    | | sampledatabase            | | schemasample              | | sys                       | | test                      | | test3                     | | tracker                   | | universitydatabase        | | web                       | | webtracker                | | ALL_DATABASE_NAME   | creationTime        | updatingTime | | test                | 2023-04-03 11:37:58 | 2023-04-03 11:38:55 | | hb_student_tracker  | 2023-03-19 03:54:32 | NULL | | sample              | 2023-03-15 00:04:29 | 2023-03-08 16:06:09 | | test3               | 2023-03-12 20:29:12 | NULL | | mysql               | 2023-02-26 07:10:49 | 2023-04-03 11:38:56 | | demo                | 2023-02-19 03:27:40 | NULL                | | tracker             | 2023-02-14 19:49:55 | NULL                | | bothinnodbandmyisam | 2023-02-06 14:32:26 | 2023-02-05 18:11:14 | | commandline         | 2023-01-30 21:21:56 | NULL                | | rdb                 | 2023-01-03 19:37:43 | NULL                | | business            | 2023-01-02 17:32:17 | 2023-12-10 17:53:02 | | education           | 2023-10-06 15:07:29 | NULL                | | information_schema  | 2023-09-23 02:09:14 | NULL                | | sys                 | 2023-09-23 02:09:03 | NULL                | | performance_schema  | 2023-09-23 02:08:01 | NULL                | 15 rows in set (0.05 sec)

How To Insert A Pdf Into Google Slides

Google Slides is a free online presentation creating tool developed by Google. Today, it is widely used by users and has become a good alternative to Microsoft PowerPoint. To use Google Slides, you should have a Google account and an active internet connection. There are many ways by which you can make a presentation effective and more informative. One of these methods is to add a PDF file to your presentation. In his article, we will see how to insert a PDF into Google Slides.

All your data will be saved automatically on the cloud.

You can create new and edit existing presentations in Google Slides by signing into your account.

You can download Google Slides presentation in Microsoft PowerPoint supported format.

How to insert a PDF into Google Slides

Now, let’s talk about how to insert a PDF into Google Slides. We will describe here the following two methods:

By converting a PDF file into images.

By adding a link to your PDF file.

Below, we have described both of these methods in detail.

1] Insert a PDF into Google Slides by converting it into images

The following steps will guide you on how to insert a PDF into Google Slides by converting it into images.

Convert your PDF file into images.

Open Google Slides and sign in using your Google account.

First, convert your PDF file into images. For this, you can use free online PDF to JPG converter tools or software. There are many online tools available that let you convert your PDF files into images. Different tools have different limitations in the free plan. Therefore, you may have to try more than one PDF to image converter tool depending on the number of pages your PDF file has. After conversion, save the images in JPG or PNG image formats.

2] Insert a PDF into Google Slides by adding a link

If you want to upload the complete PDF file, you cannot do so by using the method described above. For this, you have to add a link to your PDF file in Google Slides. The steps to do this are as follows:

Open your web browser and go to Google Drive.

Upload your PDF file to Google Drive.

Create a link to your PDF file.

Copy that link and paste it into Google Slides.

Let’s see these steps in detail.

That’s it, you have successfully inserted a PDF into your Google Slides presentation.

Read: How to add audio to Google Slides.

Can you import PDF into Google Slides?

If you want to import the entire PDF file into Google Slides, you can do so by creating a link to your PDF file. After creating the link to your PDF file, you can add that link to your Google Slides presentation.

We have described both of these methods step by step above in this article.

How do I insert a PDF into slides?

You can insert a PDF into Google Slides by converting it into images or by creating the link to the same. The latter method is easy and lets you insert the entire PDF file into Google Slides. If you use the latter method, you can link a text or an image in Google Slides to your PDF file. In this article, we have covered both of these methods in detail.

I hope this helps.

Read next: How to insert Google Slides into Google Docs.

How To Find The Row

> M1

Output      [,1] [,2] [,3] [,4] [,5] [1,]  2    2    1    2   2 [2,]  2    2    2    2   1 [3,]  2    2    1    1   1 [4,]  2    1    1    1   1 > M2 Output      [,1] [,2] [,3] [,4] [,5] [1,]  1    1    2    2    1 [2,]  2    1    1    2    1 [3,]  2    2    1    1    1 [4,]  2    1    1    2    2 [5,]  2    1    1    2    2 [6,]  1    2    1    1    2 [7,]  1    1    2    1    2 [8,]  2    2    1    2    1 [9,]  2    1    1    2    2 [10,] 1    1    2    2    2 [11,] 1    1    2    1    2 [12,] 1    2    2    2    1 [13,] 2    2    2    2    1 [14,] 2    1    2    2    1 [15,] 1    2    1    1    2 [16,] 2    2    1    2    1 [17,] 2    2    1    1    1 [18,] 2    1    1    2    1 [19,] 1    1    1    2    1 > M3 Output      [,1] [,2] [,3] [,4] [,5] [1,]  1    3    3    2    1 [2,]  2    3    1    2    2 [3,]  2    2    3    3    1 [4,]  1    3    1    3    2 [5,]  3    1    2    1    2 [6,]  2    3    1    1    1 [7,]  2    2    2    3    1 [8,]  1    2    2    2    2 [9,]  2    1    2    1    2 [10,] 1    3    1    2    1 [11,] 2    1    3    1    1 [12,] 1    1    3    2    2 [13,] 2    1    1    1    2 [14,] 2    1    3    3    2 [15,] 1    2    3    1    2 [16,] 1    2    1    2    1 [17,] 3    1    1    3    2 [18,] 3    3    3    3    1 [19,] 3    2    3    1    1 > M4 Output       [,1] [,2] [,3] [,4] [,5] [1,]  10    10   9    10   9 [2,]  9     9    10   9    9 [3,]  9     9    9    10   10 [4,]  10    9    9    10   10 [5,]  10    10   9    10   9 [6,]  10    10   9    10   10 [7,]  9     9    9    10   9 [8,]  9     10   9    10   9 [9,]  9     9    9    9    9 [10,] 9     10   9    10   9 [11,] 10    10   9    9    9 [12,] 9     9    9    9    9 [13,] 10    10   10   9 10 [14,] 10    9    10   10 10 [15,] 9     10   9    10 9 [16,] 9     10   9    10 9 [17,] 9     10   10   9 10 [18,] 9     9    9    9 10 [19,] 10    9    9    10 9

Know How To Create And Insert Favicon In Html File?

Introduction to HTML Favicon

Web development, programming languages, Software testing & others


The primary meta tag is given below to link to the web page.

How to Create HTML Favicon?

A web designer creates their personalized icon and associates them with the web page. Browsers that support a favicon display it in their particular address bars, achieving this through two means. Secondly, it displays with the tabbed document interface in the next link. Even when selected from their hard drive, the favicon must, most importantly, use the (.ico) file format. There are a few free services that can convert the image.

Once a developer completes the design of a website, they add a favicon. Simply it replaces a blank document icon on the browser tab with an official web page icon. This enables a user to make a website more accessible or find a more accessible website. The most popular search engine, Google, impresses or identifies with the user through its logo theme. As the icon is too small, it should be clear for the user to understand. There are different methods to create a Favicon. Method 1 – automatic generation using File Manager, Method -2: Uploading a regular image.

Generating an image with a size of 16 x 16 pixels (Recognition of an image). Here, you can resize the image to make it tiny for use as a favicon.

Make a conversion to a chúng tôi file format for the browser’s understanding.

Uploading a generated icon into the website.

The next step is adding the code to HTML. You can even use a favicon as a desktop or Apple icon.

How to Insert Favicon in HTML File?

You can also create the favicon with a transparent background, using either .gif or .png format. The question may arise why do we need a favicon? The answer is very simple: branding and marketing our website worldwide. The little icon makes a web page a little more professional. You add the favicon to an HTML file, which must have a particular characteristic. You can add or change the favicon on the website at any time.

Standard Name with a File Format: Once an image is created and named, the default has a chúng tôi (ICO files done with X-ICON Editor).

Size of an Image File:16 * 16, 64 * 64, 128 * 128 pixels, and files should not exceed 100KB.

Colour: maybe 8 bites, 24 or 32 bites

Image: Should be in gif or png format.

Icon Location path: It’s a standard implementation.

The next code is used for IOS users:


EDUCBA  icon EDUCBA Icon Icon is added to the address bar


Code Explanation: I have created a small oval icon in the above code and converted it into a favicon. We note that an icon displays in Internet Explorer, but many browsers do not support it. IE takes the icon from the root directory. The HTML file displays a 404 error from the server response if no specified path exists. You’ll likely need to empty your website’s cache to update the favicon since web browsers persistently hold onto cached favicons.

Note: Although with the successful completion of the favicon creation, it is not visible in all the browser tabs. The good compatibility is with Internet Explorer 5.0+ and Netscape 7.0 +. Most modern browsers support different graphical formats as their favicon. The problem arises when a server is not well configured: It is necessary to create the root has type= “image/x-icon .ico format.


Coming to the end, the favicon logo plays a vital role in website development, and also, we have seen various methods in creating a favicon, thereby achieving compatibility in cross-browser. This icon helps in creating a visual specification with the domain name. Adding them to the website is easy as they guide site recognition and branding and support the web designer to mark their professionalism.

Recommended Articles

This is a guide to HTML Favicon. Here we discuss the definition, how to create and insert an HTML favicon, and a different example and its code implementation. You may also look at the following articles to learn more –

Update the detailed information about Mysql Insert Into Query: How To Add Row In Table (Example) on the website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!