.NET Answers

ASP.NET, HTML, CSS, Visual Studio, CSharp, VB.NET and other programming items of interest.
Subscribe
  • Home
  • About Me
  • Advertising
  • Click Here to Ask a question
    • Privacy Policy
  • Site Map

Basic SQL Commands – SQL For Programmers

September 18, 2008 By: Dave

Before we get into the specifics of the commands that can be used within a stored procedure, I think it would be helpful to review some of the more basic commands that we can use that don’t really need a whole lot of discussion.

I know I said I wasn’t going to spend a lot of time on the basics, but my research indicates that a lot of people are searching for basic sql commands and very few sites are addressing that issue specifically.

So, if this is unhelpful to you, just consider this Dave’s SEO experiment.

Basic SQL Commands

Command Description
SELECT The SELECT statement returns a set of records from a table or view.  It can be used in combination with JOIN to return a set of records that are a mashup of records from multiple tables but the end result from a programming perspective is that it looks like it came from one table.  The set of records returned can be narrowed by using the WHERE clause and the order that they are returned can be set by using the ORDER BY clause.

Most common form:
SELECT field1, field2, etc FROM tableName WHERE conditions ORDER BY listOfFields

INSERT INSERT adds new records to the table.  This can be used in combination with a sub-SELECT to insert records from another table into the current table.

Most common form:
INSERT INTO tableName(field1,field2) VALUES(value1,value2)

UPDATE This is most often used in combination with the WHERE clause to update a record in a table.

Most common form:
UPDATE tableName SET field1=value1, field2=value2 WHERE condition

DELETE When you need to delete a record in your table, or a set of records, you will use the DELETE statement.

Most common form:
DELETE FROM tableName WHERE condition

WHERE The WHERE clause specifies what set of records the operation should be performed on.  We have discussed various operators in previous posts.  The most common are: =, <>, <, >, IN, and LIKE
IN IN is used with the WHERE clause to determine if the field is equal to any of the items in a list.
LIKE We discussed this one a few posts ago.  Most are familiar with the common form, LIKE ‘%content%’ to determine if ‘content’ is in the field.  But there are other useful forms of this operator as well.  Check out the list of previous posts below.
ORDER BY Most often used with the SELECT statement (and I really can’t think of any other place it is used), this controls the order the records are returned.  Most often this is a list of fields.  By default it lists everything in ascending order.  If you want the items in descending order, use the DESC modifier.

My favorite resource for SQL syntax reference is http://www.w3schools.com/sql/.

 

Other post in SQL For Programmers
  • SQL For Developers - 9 Reasons to bother - August 13th, 2008
  • SQL for Programmers - CREATE/DROP Database - August 20th, 2008
  • SQL For Programmers - CREATE TABLE - August 22nd, 2008
  • SQL For Programmers - ALTERing the TABLE - September 1st, 2008
  • SQL For Programmers - Finding a String - September 3rd, 2008
  • SQL For Programmers - Finding IN a List - September 8th, 2008
  • SQL For Programmers - Stored Procedures (Better than LINQ) - September 10th, 2008
  • SQL For Programmers - Stored Procedure Basics - September 16th, 2008
  • Basic SQL Commands - SQL For Programmers - September 18th, 2008
  • SQL IF/WHILE Blocks - SQL For Programmers - September 30th, 2008
  • SQL WHILE - SQL For Programmers - October 2nd, 2008
  • Temporary Tables - SQL For Programmers - October 7th, 2008
  • SQL CURSOR - SQL For Programmers - October 13th, 2008
  • SQL CURSOR Performance - SQL For Programmers - October 22nd, 2008
  • Random in SQL - SQL For Programmers - November 4th, 2008
  • SQL - Filtering WHERE condition on two rows - November 26th, 2008
  • SQL - Transactions - April 15th, 2009

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

Related Post

  • SQL For Programmers – Finding IN a List
  • SQL – Filtering WHERE condition on two rows
  • Random in SQL – SQL For Programmers
Bookmark to:

Add to Del.icio.us Add to digg Add to DotNetKicks Add to DZone Add to Facebook Add to Slashdot Add to Stumble Upon Add to Technorati
Hide Sites
Tags: basic sql commands, delete, in, insert, like, ms-sql, order by, select, sql, sql commands, tsql, update, where

Comments are closed.

← DotNetNuke Modules – Caching
Friday Books – Code Complete →
  • Search

  • Subscribe

    U COMMENT
    I FOLLOW

    Subscribe in a reader

    OR

    Subscribe via e-mail

    Enter your email address: 

    Delivered by FeedBurner

     

  • Follow Me

    • Twitter
    • FaceBook
    • Digg
    • StumbleUpon
    • Propeller
    • Delicious
    • Plaxo

     

  • Recent Posts

    • ASUS Eee PC 1005HA-PU1X-BK Black Netbook
    • jQuery – Date Picker
    • Using VB.NET From CSharp
    • iTextSharp – Adding Images
    • Hungarian Notation – Use What Works, Spit Out The Bones
    • Pre Order Windows 7
    • jQuery Dialog – With Validation Controls
    • iTextSharp – The easy way
    • Structure of my ASP.NET Web Applications
    • 35% Off Accronis True Image 2009 Home
    • VB.NET Hide Module Name
    • ASP.NET/VB.NET – Video Training
    • Does jQuery Make Us Lazy?
    • PDFs Using iTextSharp
    • Programming SEO – Ping



  • Advertise on this site through Lake Quincy Media
  • DotNetNuke Sponsor

     

    Most Valuable Blogger
  • Sponsor

  • Categories

    • Advanced CSharp
    • Advanced VB.NET
    • ASP.NET MVC
    • Did you know
    • DotNetNuke – Module Development
    • DotNetNuke – Skinning
    • internationalization
    • iTextSharp
    • jQuery
    • none
    • Seach Engine Optimization
    • Silverlight
    • SQL For Programmers
    • Twitter
    • winforms
  • Cloud

    .net ajax architecture asp.net book books containers csharp css dal dataset datasets dotnetnuke events gridview images internationalization internet explorer javascript jQuery json linq listview modules ms-sql MVC objectdatasource programming reflection seo Silverlight skinning sql testing tsql tutorial Twitter twitterizer vb.net video view Vista visual studio webservice WordPress
  • Archives

    • July 2009
    • June 2009
    • May 2009
    • April 2009
    • March 2009
    • February 2009
    • January 2009
    • December 2008
    • November 2008
    • October 2008
    • September 2008
    • August 2008
    • July 2008
    • June 2008
    • May 2008
    • April 2008
    • March 2008
    • February 2008
    • January 2008
    • December 2007
    • November 2007
    • October 2007
  • Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
    • Privacy Policy
  • Calendar

    September 2008
    S M T W T F S
    « Aug   Oct »
     123456
    78910111213
    14151617181920
    21222324252627
    282930  
  • Blogroll

    • Alvin Ashcraft’s Morning Dew
    • ASP.NET Consulting
    • Life Hacker
    • Remember Anything
    • The Price of Their Toys
    • Uncategorized Thought


.NET Answers © 2007 - 2008 All Rights Reserved.
Entries and Comments.