{"id":23006,"date":"2024-02-20T19:17:13","date_gmt":"2024-02-20T18:17:13","guid":{"rendered":"https:\/\/nelkodev.com\/blog\/principales-funciones-en-sql-aprende-a-dominar-el-lenguaje-de-consulta-estructurada\/"},"modified":"2024-06-03T17:30:43","modified_gmt":"2024-06-03T16:30:43","slug":"principales-funciones-en-sql-aprende-a-dominar-el-lenguaje-de-consulta-estructurada","status":"publish","type":"post","link":"https:\/\/nelkodev.com\/en\/programming\/main-functions-in-sql-learn-to-master-the-structured-query-language\/","title":{"rendered":"Main functions in SQL: Learn to master the structured query language"},"content":{"rendered":"<p>The structured query language, better known as SQL, is one of the fundamental pillars in the world of programming and databases. With SQL we can perform various operations on stored data, such as queries, insertions, updates and deletions.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_80 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #ffffff;color:#ffffff\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #ffffff;color:#ffffff\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewbox=\"0 0 24 24\" version=\"1.2\" baseprofile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/nelkodev.com\/en\/programming\/main-functions-in-sql-learn-to-master-the-structured-query-language\/#Consulta_de_datos_con_SELECT\" >Data query with SELECT<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/nelkodev.com\/en\/programming\/main-functions-in-sql-learn-to-master-the-structured-query-language\/#Insercion_de_datos_con_INSERT\" >Inserting data with INSERT<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/nelkodev.com\/en\/programming\/main-functions-in-sql-learn-to-master-the-structured-query-language\/#Actualizacion_de_datos_con_UPDATE\" >Updating data with UPDATE<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/nelkodev.com\/en\/programming\/main-functions-in-sql-learn-to-master-the-structured-query-language\/#Eliminacion_de_datos_con_DELETE\" >Deleting data with DELETE<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/nelkodev.com\/en\/programming\/main-functions-in-sql-learn-to-master-the-structured-query-language\/#Otras_funciones_utiles\" >Other useful functions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/nelkodev.com\/en\/programming\/main-functions-in-sql-learn-to-master-the-structured-query-language\/#Preguntas_frecuentes\" >Frequently asked questions<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/nelkodev.com\/en\/programming\/main-functions-in-sql-learn-to-master-the-structured-query-language\/#1_%C2%BFQue_es_SQL\" >1. What is SQL?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/nelkodev.com\/en\/programming\/main-functions-in-sql-learn-to-master-the-structured-query-language\/#2_%C2%BFCual_es_la_funcion_principal_de_SELECT\" >2. What is the main function of SELECT?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/nelkodev.com\/en\/programming\/main-functions-in-sql-learn-to-master-the-structured-query-language\/#3_%C2%BFQue_es_una_clausula_WHERE\" >3. What is a WHERE clause?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/nelkodev.com\/en\/programming\/main-functions-in-sql-learn-to-master-the-structured-query-language\/#4_%C2%BFComo_puedo_actualizar_datos_en_SQL\" >4. How can I update data in SQL?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/nelkodev.com\/en\/programming\/main-functions-in-sql-learn-to-master-the-structured-query-language\/#5_%C2%BFCual_es_la_diferencia_entre_DELETE_y_TRUNCATE\" >5. What is the difference between DELETE and TRUNCATE?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Consulta_de_datos_con_SELECT\"><\/span>Data query with SELECT<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>One of the most basic and essential functions in SQL is querying data using the SELECT statement. This function allows us to select and retrieve data from a table or set of tables in a database. We can specify the fields we want to retrieve, as well as apply conditions and filters using clauses such as WHERE and ORDER BY.<\/p>\n<p>For example, if we want to get the names and ages of all users over 18 years old from a table called &quot;users&quot;, we can use the following query:<\/p>\n<pre>\nSELECT name, age FROM users WHERE age &gt; 18;\n<\/pre>\n<p>There are many other clauses and operators that can be used in conjunction with SELECT to perform more complex data queries, such as JOIN, GROUP BY, HAVING, among others.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Insercion_de_datos_con_INSERT\"><\/span>Inserting data with INSERT<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Another important function in SQL is inserting data into a table. The INSERT statement allows us to add records to a specific table, specifying the values for each column. For example, if we have a table called &quot;customers&quot; with the columns &quot;name&quot; and &quot;email&quot;, we can use the following query to add a new customer:<\/p>\n<pre>\nINSERT INTO clients (name, email) VALUES (&#039;John Doe&#039;, &#039;johndoe@gmail.com&#039;);\n<\/pre>\n<p>It is important to note that we must specify the values in the same order as the columns in the table. Additionally, we can use the INSERT statement in conjunction with the SELECT statement to insert data from another table.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Actualizacion_de_datos_con_UPDATE\"><\/span>Updating data with UPDATE<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The UPDATE statement allows us to update the values of one or more columns in existing records in a table. This is useful when we want to modify specific information in our databases. For example, if we want to update the name of a user in a table called &quot;users&quot;, we can use the following query:<\/p>\n<pre>\nUPDATE users SET name = &#039;Jane Doe&#039; WHERE id = 1;\n<\/pre>\n<p>It is important to specify the condition using the WHERE clause to indicate which records should be updated.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Eliminacion_de_datos_con_DELETE\"><\/span>Deleting data with DELETE<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The DELETE statement allows us to delete records from a table in a database. This feature is useful when we want to delete information that is no longer relevant or does not meet certain criteria. For example, if we want to remove all users under 18 from a table called &quot;users&quot;, we can use the following query:<\/p>\n<pre>\nDELETE FROM users WHERE age < 18;\n<\/pre>\n<p>It is important to be careful when using the DELETE statement, as it can permanently delete data.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Otras_funciones_utiles\"><\/span>Other useful functions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In addition to the main functions mentioned above, SQL has a wide variety of other functions that allow us to perform more specific actions, such as:<\/p>\n<ul>\n<li>Aggregation functions: SUM, AVG, COUNT, MAX, MIN.<\/li>\n<li>Date and time functions: GETDATE, DATEPART, DATEADD.<\/li>\n<li>Text functions: LEN, UPPER, LOWER, SUBSTRING.<\/li>\n<li>String manipulation functions: CONCAT, REPLACE, CHARINDEX.<\/li>\n<\/ul>\n<p>These are just some of the main functions in SQL, but there are many others that can be used according to the specific needs of each project.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Preguntas_frecuentes\"><\/span>Frequently asked questions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"1_%C2%BFQue_es_SQL\"><\/span>1. What is SQL?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>SQL is a structured query language used to manage and manipulate relational databases. It allows operations such as queries, insertions, updates and deletions of data.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"2_%C2%BFCual_es_la_funcion_principal_de_SELECT\"><\/span>2. What is the main function of SELECT?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The main function of SELECT in SQL is to perform data queries, retrieving specific information from one or more tables in a database.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"3_%C2%BFQue_es_una_clausula_WHERE\"><\/span>3. What is a WHERE clause?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The WHERE clause is used in SQL to filter records in a query, applying specific conditions to the retrieved data.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"4_%C2%BFComo_puedo_actualizar_datos_en_SQL\"><\/span>4. How can I update data in SQL?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>To update data in SQL, the UPDATE statement is used along with the SET clause to specify the values to change, and the WHERE clause to indicate which records should be updated.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"5_%C2%BFCual_es_la_diferencia_entre_DELETE_y_TRUNCATE\"><\/span>5. What is the difference between DELETE and TRUNCATE?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The DELETE statement is used to delete specific records from a table, while TRUNCATE is used to delete all records from a table, without affecting its structure.<\/p>\n<p>In conclusion, the main functions in SQL allow us to perform essential operations in database management. Learning to use these functions appropriately is essential to take full advantage of the potential of SQL and be able to manage information efficiently.<\/p>","protected":false},"excerpt":{"rendered":"<p>El lenguaje de consulta estructurada, m\u00e1s conocido como SQL, es uno de los pilares fundamentales en el mundo de la programaci\u00f3n y bases de datos. Con SQL podemos realizar diversas operaciones con los datos almacenados, como consultas, inserciones, actualizaciones y eliminaciones. Consulta de datos con SELECT Una de las funciones m\u00e1s b\u00e1sicas y esenciales en [&hellip;]<\/p>","protected":false},"author":1,"featured_media":23007,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[420,16],"tags":[486,205,881,480,880,147,481,146,101,504],"class_list":["post-23006","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","category-programacion","tag-aprende","tag-blog","tag-consulta","tag-dominar","tag-estructurada","tag-funciones","tag-lenguaje","tag-principales","tag-programacion","tag-sql"],"_links":{"self":[{"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/posts\/23006","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/comments?post=23006"}],"version-history":[{"count":0,"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/posts\/23006\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/media\/23007"}],"wp:attachment":[{"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/media?parent=23006"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/categories?post=23006"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nelkodev.com\/en\/wp-json\/wp\/v2\/tags?post=23006"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}