Skip to main content

How To Insert Multiple Rows In A Single Query in MySql

Sometimes, it is needed to insert multiple columns at a time. Next MySQL multiple insert queries performs perfect, of course
INSERT INTO
  table_name (column-1, column-2, ... , column-n)
  VALUES (value-1-1, value-1-2, ... , value-1-n);
INSERT INTO
  table_name (column-1, column-2, ... , column-n)
  VALUES (value-2-1, value-2-2, ... , value-2-n);

  ...
INSERT INTO
  table_name (column-1, column-2, ... , column-n)
  VALUES (value-m-1, value-m-2, ... , value-m-n);

But next single query is easy to use and save memory ant time
INSERT INTO
  table_name (column-1, column-2, ... , column-n)
  VALUES
    (value-1-1, value-1-2, ... , value-1-n),
    (value-2-1, value-2-2, ... , value-2-n),
    ... ,
   (value-m-1, value-m-2, ... , value-m-n);

But be careful with large data (value). Your server or machine might be stop the execution due to the security or resource issues such as execution time limit.

Comments

Popular posts from this blog

Google's Favorite Colors By Hex Codes (With New Google Logo)

Google keeps its color scheme cross their products. Of course, each uses different colors but it keeps the main philosophy. I heard that the test period for new Google logo was more than one year. It may the reason that the colors are comfortable to look. Sometimes, I copy the colors for designing my blogs and web sites. Copyright? oh..

Color Conversion: RGB to HEX , HEX to RGB

Color conversion between RGB and Hex is needed sometimes even though HTML and CSS accepts both RGB and HEX codes for set color scheme of HTML elements. The conversion algorithm is simple. Then numbers in RGB format is decimal number and one in HEX code is hexadecimal number. For example, rgb(50, 100, 250) is same in HEX #3264FA: 50-32 | 100-64 | 250-FA.

Why Blogger Mobile Template Not Work?

Google Blogger shows blog pages with mobile CSS on mobile devices unless you change it disabled. You can see next figure by clicking mobile setting button on Template page. Since I want to change CSS and I remember there are some CSS elements starting with '.mobile', I open the template editor and edit as I want. And open my blog in my smart phone. Nothing changed.