Www-w3schools-Com SQL SQL Syntax-ASP Bccxi4fo
Www-w3schools-Com SQL SQL Syntax-ASP Bccxi4fo
Searchw3schools.com Search
H O M E H T M L C S S X M L J A V A S C R I P T A S P P H P S Q L MORE...
SQLBasic
SQLHOME SQLIntro SQLSyntax SQLSelect SQLDistinct SQLWhere SQLAnd&Or SQLOrderBy SQLInsert SQLUpdate SQLDelete
SQLSyntax
Previous NextChapter
DatabaseTables
Adatabasemostoftencontainsoneormoretables.Eachtableisidentifiedbyaname(e.g. "Customers"or"Orders").Tablescontainrecords(rows)withdata. Belowisanexampleofatablecalled"Persons": P_Id 1 2 3 LastName Hansen Svendson Pettersen FirstName Ola Tove Kari Address Timoteivn10 Borgvn23 Storgt20 City Sandnes Sandnes Stavanger
SQLDemo
SQLTryIt
SQLAdvanced
SQLTop SQLLike SQLWildcards SQLIn SQLBetween SQLAlias SQLJoins SQLInnerJoin SQLLeftJoin SQLRightJoin SQLFullJoin SQLUnion SQLSelectInto SQLCreateDB SQLCreateTable SQLConstraints SQLNotNull SQLUnique SQLPrimaryKey SQLForeignKey SQLCheck SQLDefault SQLCreateIndex SQLDrop SQLAlter SQLIncrement SQLViews SQLDates SQLNulls SQLisnull() SQLDataTypes
Thetableabovecontainsthreerecords(oneforeachperson)andfivecolumns(P_Id,LastName, FirstName,Address,andCity).
SQLStatements
MostoftheactionsyouneedtoperformonadatabasearedonewithSQLstatements. ThefollowingSQLstatementwillselectalltherecordsinthe"Persons"table:
SELECT*FROMPersons
InthistutorialwewillteachyouallaboutthedifferentSQLstatements.
KeepinMindThat...
l
SQLisnotcasesensitive
SQLFunctions
SQLFunctions SQLavg() SQLcount() SQLfirst() SQLlast() SQLmax() SQLmin() SQLsum() SQLGroupBy SQLHaving SQLucase() SQLlcase() SQLmid() SQLlen() SQLround() SQLnow() SQLformat() SQLQuickRef SQLHosting SQLSummary
SemicolonafterSQLStatements?
SomedatabasesystemsrequireasemicolonattheendofeachSQLstatement. SemicolonisthestandardwaytoseparateeachSQLstatementindatabasesystemsthatallow morethanoneSQLstatementtobeexecutedinthesamecalltotheserver. WeareusingMSAccessandSQLServer2000andwedonothavetoputasemicolonaftereach SQLstatement,butsomedatabaseprogramsforceyoutouseit.
SQLDMLandDDL
SQLcanbedividedintotwoparts:TheDataManipulationLanguage(DML)andtheDataDefinition Language(DDL). ThequeryandupdatecommandsformtheDMLpartofSQL:
l l l l
SQLQuiz
SQLQuiz
INSERTINTO insertsnewdataintoadatabase
CREATEDATABASE createsanewdatabase ALTERDATABASE modifiesadatabase CREATETABLE createsanewtable ALTERTABLE modifiesatable DROPTABLE deletesatable CREATEINDEX createsanindex(searchkey) DROPINDEX deletesanindex
Previous
WEBHOSTING BestWebHosting PHPMySQLHosting Top10WebHosting UKResellerHosting CloudHosting TopWebHosting $7.95/moSEOHosting WEBBUILDING XMLEditorFreeTrial! FREEWebsiteBUILDER FreeWebsiteTemplates FreeWordPressThemes W3SCHOOLSEXAMS GetCertifiedin: HTML,CSS,JavaScript, XML,PHP,andASP W3SCHOOLSBOOKS NewBooks: HTML,CSS JavaScript,andAjax STATISTICS BrowserStatistics BrowserOS BrowserDisplay SHARETHISPAGE Sharewith
NextChapter
W3Schoolsisoptimizedforlearning,testing,andtraining.Examplesmightbesimplifiedtoimprovereadingandbasicunderstanding.