Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Returning all data from a table
Select some columns
Filtering rows
Logic
Text patterns
14. Use text
To be or NULL to be
A bit of mathematics
Let's practice

Instruction

Until now, we only worked with numbers in our WHERE clauses. Is it possible to use text (also known as a string) instead of numbers? Of course! Just remember to put your string in single quotes like this: 'example'.

If you wanted to know the age of all Smiths in your table, you could use the following code:

SELECT
  Age
FROM User
WHERE Name = 'Smith';

Note that the case of the letters matters, (i.e., 'Smith' can be different than 'SMITH'). Whether these two versions actually differ depends on the setup of your SQL Server. It is common in SQL Server to use the case-insensitive setting, where two strings with different cases will be treated as the same (we also use this setting in this course). It's important to remember, however, that it's possible for two such strings to be treated as different strings if a different setting is used.

Exercise

Select all columns for Ford cars.

Stuck? Here's a hint!

Type:

SELECT
  *
FROM Car
WHERE Brand = 'Ford';