SQL INSERT INTO Statement

The SQL INSERT INTO syntax

The general syntax is:

  1. INSERT INTO tablename (columnnames)
  2. VALUES (values)

 


 

SQL INSERT INTO Examples

Problem: Add a record for a new customer

  1. INSERT INTO Customer (FirstName, LastName, City, Country, Phone)
  2. VALUES (‘Craig’, ‘Smith’, ‘New York’, ‘USA’, 101993 2800)

Results: 1 new record inserted


Problem: Add a new customer named Anita Coats to the database

  1. INSERT INTO Customer (FirstName, LastName)
  2. VALUES (‘Anita’, ‘Coats’)

Results: 1 new record inserted


 

The SQL INSERT combined with a SELECT

The general syntax is:

  1. INSERT INTO tablename (columnnames)
  2. SELECT columnnames
  3. FROM tablename
  4. WHERE condition

 


 

SQL INSERT INTO with SELECT Example

Problem: The Bigfoot Brewery supplier is also a customer.
Add a customer record with values from the supplier table.

  1. INSERT INTO Customer (FirstName, LastName, City, Country, Phone)
  2. SELECT LEFT(ContactName, CHARINDEX(‘ ‘,ContactName) 1),
  3. SUBSTRING(ContactName, CHARINDEX(‘ ‘,ContactName) + 1, 100),
  4. City, Country, Phone
  5. FROM Supplier
  6. WHERE CompanyName = ‘Bigfoot Breweries’

Note: ContactName is parsed into FirstName and LastName.
Parsing takes place with built-in functions: LEFT, SUBSTRING, and CHARINDEX.
Results: 1 new record inserted

Comments (64)

  1. Pingback: best trap 2021

  2. Pingback: mơ thấy đi trên nước

  3. Pingback: Male sex dolls

  4. Pingback: Rock Island Armory VR80

  5. Pingback: Buy GLOCK 43X near me

  6. Pingback: mơ thấy rắn hổ mang đánh con gì

  7. Pingback: stiiizy carts online / where to buy stiiizy carts online

  8. Pingback: con gái cung thiên bình

  9. Pingback: 7lab pharma clenbuterol reviews

  10. Pingback: mơ bị đứt tay

  11. Pingback: replicas panerai pam 251

  12. Pingback: mơ thấy ăn chuối chín

  13. Pingback: Tyson vs Jones jr live

  14. Pingback: best cbd reddit

  15. Pingback: hemp store jackson tn

  16. Pingback: Software Functional Testing

  17. Pingback: mơ thấy chim bồ câu đánh con gì

  18. Pingback: mơ thấy con sâu

  19. Pingback: mơ cá trê đánh con gì

  20. Pingback: mơ thấy thầy bói

  21. Pingback: nằm mơ thấy hoa sen

  22. Pingback: mơ thấy con trâu đánh đề con gì

  23. Pingback: nằm mơ thấy ốc đánh con gì

  24. Pingback: w88club ทางเข้า

  25. Pingback: 먹튀검증

  26. Pingback: mơ thấy cháy rừng

  27. Pingback: kimber micro 9 for sale

  28. Pingback: https://www.pornachi.com/porn/madison-ivy-hd-tube/

  29. Pingback: bmo online banking signon

  30. Pingback: dumps with pin legit

  31. Pingback: Mossberg firearms

  32. Pingback: maryland crabs

  33. Pingback: little nightmares 2

  34. Pingback: 풀팟포커

  35. Pingback: Pax Era Pods

  36. Pingback: White House Market Link

  37. Pingback: 오밤

  38. Pingback: world market link

  39. Pingback: ดูบอลออนไลน์

  40. Pingback: free coupons

  41. Pingback: setup clickcease

  42. Pingback: hotel tonight app

  43. Pingback: W88

  44. Pingback: villas around Hyderabad

  45. Pingback: baixe o aplicativo alterado

  46. Pingback: precista watch for sale

  47. Pingback: hackear whatsapp online

Leave a comment

이메일 주소는 공개되지 않습니다.