{"id":45,"date":"2013-09-12T14:53:12","date_gmt":"2013-09-12T14:53:12","guid":{"rendered":"http:\/\/passionwind.com\/techref\/?p=45"},"modified":"2022-11-11T20:39:11","modified_gmt":"2022-11-12T01:39:11","slug":"sql-syntax-basic-commands","status":"publish","type":"post","link":"http:\/\/techref.camellarry.com\/?p=45","title":{"rendered":"SQL Basic Command Syntax"},"content":{"rendered":"<div>I use SQL statements on an almost daily basis, yet I have trouble remembering the syntax of even the most basic commands.\u00a0 Thus I\u00a0decided to post a cheat sheet here for quick and easy reference.\u00a0 I hope you may find it valuable.<\/div>\n<table cellpadding=\"5\">\n<tbody>\n<tr>\n<td>Selecting Records<\/td>\n<td>SELECT * FROM\u00a0Table\u00a0WHERE\u00a0Param1\u00a0&lt; 10 ORDER BY\u00a0Param2<\/td>\n<\/tr>\n<tr>\n<td>Selecting Records Into a New Table<\/td>\n<td>SELECT * INTO newdb.dbo.newtable FROM olddb.dbo.oldtable<\/td>\n<\/tr>\n<tr>\n<td>Updating Records<\/td>\n<td>UPDATE\u00a0Table\u00a0SET\u00a0Param1\u00a0= \u2018cat\u2019,\u00a0Param3\u00a0= \u2018fish\u2019 WHERE\u00a0Param2\u00a0= \u2018dog\u2019<\/td>\n<\/tr>\n<tr>\n<td>Adding Records<\/td>\n<td>INSERT INTO\u00a0Table (Param1, Param2) VALUES (\u2018xx\u2019, \u2018yy\u2019)<\/td>\n<\/tr>\n<tr>\n<td>Deleting Records<\/td>\n<td>DELETE FROM\u00a0Table\u00a0WHERE\u00a0Param1\u00a0= \u2018value\u2019<\/td>\n<\/tr>\n<tr>\n<td>Group By<\/td>\n<td>SELECT\u00a0column_name,\u00a0aggregate_function(column_name) FROM\u00a0table_name WHERE\u00a0column_name\u00a0= value GROUP BY\u00a0column_name<\/td>\n<\/tr>\n<tr>\n<td>List all tables &amp;\u00a0views in database<\/td>\n<td>SELECT TABLE_TYPE, TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES ORDER BY TABLE_TYPE, TABLE_NAME<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>I use SQL statements on an almost daily basis, yet I have trouble remembering the syntax of even the most basic commands.\u00a0 Thus I\u00a0decided to post a cheat sheet here for quick and easy reference.\u00a0 I hope you may find it valuable. Selecting Records SELECT * FROM\u00a0Table\u00a0WHERE\u00a0Param1\u00a0&lt; 10 ORDER BY\u00a0Param2 Selecting Records Into a New [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[8],"tags":[70,72],"class_list":["post-45","post","type-post","status-publish","format-standard","hentry","category-sql","tag-sql","tag-syntax"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9t3oE-J","_links":{"self":[{"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=\/wp\/v2\/posts\/45","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=45"}],"version-history":[{"count":5,"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=\/wp\/v2\/posts\/45\/revisions"}],"predecessor-version":[{"id":491,"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=\/wp\/v2\/posts\/45\/revisions\/491"}],"wp:attachment":[{"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=45"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=45"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=45"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}