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

“SQL INSERT INTO Statement”의 52개의 댓글

  1. 핑백: best trap 2021

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

  3. 핑백: Male sex dolls

  4. 핑백: Rock Island Armory VR80

  5. 핑백: Buy GLOCK 43X near me

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

  7. 핑백: stiiizy carts online / where to buy stiiizy carts online

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

  9. 핑백: 7lab pharma clenbuterol reviews

  10. 핑백: mơ bị đứt tay

  11. 핑백: replicas panerai pam 251

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

  13. 핑백: Tyson vs Jones jr live

  14. 핑백: best cbd reddit

  15. 핑백: hemp store jackson tn

  16. 핑백: Software Functional Testing

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

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

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

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

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

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

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

  24. 핑백: w88club ทางเข้า

  25. 핑백: 먹튀검증

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

  27. 핑백: kimber micro 9 for sale

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

  29. 핑백: bmo online banking signon

  30. 핑백: dumps with pin legit

  31. 핑백: Mossberg firearms

  32. 핑백: maryland crabs

  33. 핑백: little nightmares 2

  34. 핑백: 풀팟포커

  35. 핑백: Pax Era Pods

  36. 핑백: White House Market Link

  37. 핑백: 오밤

  38. 핑백: world market link

  39. 핑백: ดูบอลออนไลน์

  40. 핑백: free coupons

  41. 핑백: setup clickcease

  42. 핑백: hotel tonight app

  43. 핑백: W88

  44. 핑백: villas around Hyderabad

  45. 핑백: baixe o aplicativo alterado

  46. 핑백: precista watch for sale

  47. 핑백: hackear whatsapp online

답글 남기기