9 May 2024 Martyna Sławińska SQL String Functions: A Complete Overview A review of all core SQL string functions, including their definitions and examples. SQL string functions manipulate string (including text and alphanumeric) values. Also known as text functions in SQL, string functions take one or more string values as an argument and return a modified string value. Check out this interactive course on Standard SQL Functions if you want more hands-on practice than this article includes. It provides 211 exercises on numeric SQL functions, string or text functions, date and time functions, and aggregate functions. Read more 25 Aug 2021 LearnSQL.com Team Standard SQL Functions Cheat Sheet Welcome to the ultimate resource for mastering SQL functions - the Standard SQL Functions Cheat Sheet. It's designed to be a quick yet comprehensive reference guide for both beginners and experts. Download yours and start querying with ease. Whether you are a beginner stepping into the world of SQL or a seasoned professional looking to brush up on your skills, our Standard SQL Functions Cheat Sheet is designed to be your go-to guide for SQL functions. Read more Latest Articles 20 Jul 2023 Tihomir Babic A Complete Guide to Working With Substrings in SQL In this article, we’ll discuss how to work with substrings in SQL. It involves learning several approaches, so we’ll show you their ins and outs. To work with substrings in SQL, we first need to know what a string is. In programming, a string is any kind of textual data (a title, a description, a name). A string consists of any number and type of characters. In a SQL database, strings are typically stored as CHAR or VARCHAR data types. Read more 16 Feb 2023 Alexandre Bruffa How to Concatenate Two Columns in SQL – A Detailed Guide In SQL, concatenation is the operation of joining together strings, or pieces of text information. Learn how to concatenate two columns in SQL with this detailed guide. SQL concatenation is the process of combining two or more character strings, columns, or expressions into a single string. For example, the concatenation of 'Kate', ' ', and 'Smith' gives us 'Kate Smith'. Enhance your SQL skills with our interactive SQL Practice Set! This comprehensive course contains nearly 90 hands-on exercises, divided into five topic-based sections, including a section dedicated to SQL concatenation. Read more 25 Oct 2022 Tihomir Babic An Overview of SQL Text Functions in PostgreSQL If you’re a PostgreSQL user and into data analysis, you’ve heard of the text functions or maybe even used them. But what are PostgreSQL’s most popular text functions? In today’s article, we’ll show you what they are and how to use them. As anyone who works with them knows, databases don’t contain only numerical values. Among other data types, databases also store text or string data. To use PostgreSQL effectively, you’ll have to know at least some of Postgres’ text functions. Read more 24 Oct 2022 How to Compare two Strings in SQL Problem You want to to compare two strings alphabetically in SQL. Solution The most straightforward method to compare two strings in SQL is to use standard comparison operators (<, >, =, etc.): SELECT 'Michael' < 'Mike'; Here is the result: 'Michael' < 'Mike' 1 The result of 1 means 'true'. A result of 'false' would show a 0. Read more 18 Aug 2022 Tihomir Babic An Overview of SQL Text Functions in Google BigQuery Data analysts and Google BigQuery go hand in hand. Google's cloud data warehouse presents you with plenty of opportunities for using standard SQL text functions you can't avoid in your day-to-day work as a data analyst. BigQuery uses Google Standard SQL, an ANSI-compliant SQL dialect. This means you can use standard SQL text functions in BigQuery without needing to learn a variant of a given function. The Standard SQL Functions course is an excellent resource for learning those functions. Read more 7 Jul 2022 Tihomir Babic An Overview of SQL Text Functions in MySQL Do you work in MySQL as a data analyst? Then you should know how to use its text functions – data analysts don’t work only with numbers. Reporting requires computations, data classification, and label creation, and you can do all of that in MySQL. In this article, I’ll explain several of the most common and useful MySQL text functions by discussing what they do and showing how they do it. Read more 23 Jun 2022 Tihomir Babic An Overview of Microsoft SQL Server Text Functions Data analysts use text values when creating SQL reports. You can create your own labels with functions, classify rows based on text value, or do computations based on it. This article covers how to do all that. The text values in databases are not just for reading. As with numeric values, we perform operations on them and manipulate the text. SQL Server has a fair number of text functions. Read more 22 May 2022 How to Check the Length of a String in SQL Problem You want to know the number of characters in a string. Example Our database has a table named employees with data in the following columns: id (primary key), first_name, last_name, and city. idfirst_namelast_namecity 1OwenTaylorManchester 2HaroldWilkinsonManchester 3KarlGaversDallas 4MaryLarsonDallas Let’s say that we want to select the ID, last name, and city of each employee. Read more 22 Mar 2022 Tihomir Babic The SQL Substring Function in 5 Examples Working with text data in SQL? We explain how to get values from any point in a string. When you think of working with data in SQL, your first thought is probably a database full of numbers and your SQL code doing very fancy calculations. But text is data, too! It’s very common to find text data in databases. Not only do you have to extract it, but often you also have to manipulate it. Read more 24 Oct 2021 How to Change Text to Lowercase in SQL Problem You’d like to change some text to lowercase in SQL. Example Our database has a table named item with data in the following columns: id, code, and wood_type_used. The case is inconsistent in the data in the wood_type_used column. We would like all of the wood types to be displayed in lowercase. idcodewood_type_used 1000237PSHPine 2000115MCHMAHOGANY 3000073BTBbirch 400068WBDwAlnUt 500055BSHBirch Solution We’ll use the LOWER() function: Read more 28 Jul 2021 Zahin Rahman An Overview of SQL Text Functions In this article, we will discuss the ins and outs of the most common SQL text functions, which make it possible for you to find and work on string values. Before we dive into text functions, let’s quickly recap what an SQL function is. Simply put, a function is a predefined built-in piece of code that you can use in your SQL query. For example, the functions SUM(), AVG(), and COUNT() are applied to numerical variables to calculate the sum, average, and number of records respectively. Read more 4 Mar 2021 Andrew Bone What Do the Operators LIKE and NOT LIKE Do? The SQL LIKE and NOT LIKE operators are used to find matches between a string and a given pattern. They are part of standard SQL and work across all database types, making it essential knowledge for all SQL users. Gaining an understanding of these operators will allow you to write better queries and demonstrate to potential employers that you have the skills required to filter through expansive data sets. Read more 15 Feb 2020 How to Concatenate Strings in SQL Problem You want to concatenate strings from two columns of a table into one. Example Our database has a table named student with data in the following columns: id, first_name and last_name. idfirst_namelast_name 1LoraSmith 2EmilBrown 3AlexJackson 4MartinDavis Let’s append the first name to the last name of the student in one string. Use a space between each name. Read more 9 Feb 2020 How to Convert a String to Uppercase in SQL Problem You would like to convert a string to uppercase in SQL. Example Our database has a table named questionnaire with data in the following columns: id, first_name, last_name, and favorite_car. idfirst_namelast_namefavorite_car 1AlanJacksonHonda Civic 2ElisaThomsonTOYOTA Camry 3MaryMartinesNissan rogue 4ChrisBrownford focus 5AdamSpringRam PICKUP Our table stores the make and model of the favorite car for each person who filled out our questionnaire. Read more 27 Nov 2019 How to Use LIKE in SQL Problem: You need to search for specific patterns (certain combinations of letters or numbers) within text data in your database. We'll show you how to use the LIKE operator in SQL to: Find city names starting with S Find city names with exactly five characters Find city names starting with S and with o as the second-to-last character You'll also learn how to use LIKE and wildcard operators in SQL to find your own patterns in text data in your database. Read more 26 Nov 2019 How to Trim Strings in SQL Problem: You’d like to remove specific characters from the beginning and end of a string in SQL. Example: Our database has a table named post with data in two columns: id and title. idtitle 1' News about dogs ' 3'Eurovision 2019 ' 4'New political climate' Let’s trim the title of each post to remove the unnecessary space at the beginning and end. Read more 26 Nov 2019 How to Replace Part of a String in SQL Problem: You’d like to replace part of a string with another string. Example: Our database has a table named investor with data in the following columns: id, company, and phone. idcompanyphone 1Big Market123–300-400 3The Sunny Restaurant123–222-456 4My Bank123-345-400 We’d like to change the phone number format for each company by replacing the hyphen character with a space. Read more 31 Jul 2018 Aldo Zelen How to Use a SQL Wildcard SQL wildcard allows us to filter data matching certain patterns in SQL. We use SQL wildcards with the LIKE operator in the WHERE clause of a query to filter data. In this beginner’s article, we’ll look at everything you need to know about basic SQL wildcards. If you like playing cards, then you know that wildcards can substitute any other card in your deck. Similarly, SQL wildcards can substitute one or more characters. Read more 29 Mar 2018 Ignacio L. Bisso Extracting Data From a String: SPLIT_PART in PostgreSQL Learn how to use split_part in PostgreSQL to extract data from strings. Quite often, we’d like to extract parts of a string when working with text values. A common example is when we have a full name and need to retrieve only the last name. In this article, we’ll examine how to do it using split_part in PostgreSQL, i.e. a string-related function that can be used to extract a substring. Read more 9 Feb 2018 Ignacio L. Bisso How to Remove Junk Characters in SQL Unwanted characters in text data can be a bit of a pain, but there’s an easy way to fix them. Scroll down to learn how to remove junk characters in SQL in the easiest way! Sometimes, we’ll find unwanted characters inside our string data because our SQL queries didn’t work as expected. Moreover, these extra characters may sometimes be invisible, which really complicates things. In this article, we’ll examine some string-related SQL functions that can handle unwanted characters—visible or not! Read more 31 Jan 2018 Ignacio L. Bisso How to Solve Capitalization Data Quality Issues Misspelled names, typos, and text data quality issues in your database? Power up your queries! Use SQL string functions to address data quality issues related to capitalization. Sometimes, our SQL queries don't work as expected because of data quality issues. In this article, we will examine some string-related SQL functions that can correct data quality issues related to capitalization. We'll be using PostgreSQL in our examples, but similar functions are available in most database engines. Read more 5 Jan 2018 Aldo Zelen 18 Useful Important SQL Functions to Learn ASAP Learning a new programming language can seem intimidating. Like any other language, a programming language has a large vocabulary that you need to master. In this article, we’ll look at some of the most useful SQL functions that you need to know. Structured Query Language, commonly known as SQL, is the standard language for managing and querying data in relational databases. Born out of the need to efficiently interact with large datasets, SQL has become an indispensable tool for database administrators, data analysts, and developers alike. Read more 21 Dec 2017 Aldo Zelen How to Draw a Christmas Tree in SQL You can use SQL to manipulate all kinds of data, from huge analytical queries to brief single-purpose statements. But you can also use SQL just for fun, without any business requirements stifling your creativity. So, get out your jolly hat and prepare to sing O Christmas Tree as we create some quirky art with plain old SQL. Today, we’re going to generate some holiday-themed ASCII art, just for fun. That’s right. Read more 20 Apr 2017 Dorota Wdzięczna How to Use LIKE in SQL: SQL Pattern Matching SQL pattern matching is a very important and useful ability. In this article, we look at how you can perform it using LIKE in SQL. SQL Pattern matching is a very simple concept. It allows you to search strings and substrings and find certain characters or groups of characters. Apart from SQL, this operation can be performed in many other programming languages. In this article, we’ll examine how you can use LIKE in SQL to search substrings. Read more 13 Apr 2017 Marek Pankowski 5 SQL Functions for Manipulating Strings SQL functions used for manipulating strings, commonly called string functions, are among most important SQL’s tools. In this post, we’ll look at five ways you can perform various operations on strings. There are many SQL functions that let you “edit” string data. As you learn SQL, you’ll see how useful they prove. Some sql trim off unneeded spaces or characters; others tell you how long a string is. These functions give you a lot of opportunities to transform and work with strings, which makes your code more effective. Read more