How old is the oldest person with a drivers license? With a small amount of data, you might be able to just eyeball it, but there thousands of records in the drivers_license table. In fact, you learned an aggregate function above, COUNT. You may want to ask more complex questions such as “Who is the oldest person?” or “Who is the shortest person?” Aggregate functions can help you answer these questions. Sometimes the questions you want to ask aren’t as simple as finding the row of data that fits a set of criteria. LOWER(), and you can probably figure out what they do, especially if you explore in the box below. SQL provides a couple of functions which can smooth that out for you. Sometimes you don't know how the text is stored in the database. We've mentioned that SQL commands are not case-sensitive, but WHERE querie values for You can also use the keywords BETWEEN and AND - and all of those work with words as well as numbers. SQL also supports numeric comparisons like (greater than). Important: When using wildcards, you don't use the = symbol instead, you use 'B_b' would match 'Bob' and 'Bub' but not 'Babe' or This one means 'match the rest of the text, as long as there's exactly one character in exactly the position of the _, no matter what it is. The other, less commonly used wildcard, is _. When you place a % wildcard in a query string, the SQL system will return results that match the rest of the string exactly, and have anything (or nothing) where the wildcard is. Special symbols that represent unknown characters are called "wildcards," and SQL supports two. Sometimes you only know part of the information you need. Wildcards and other functions for partial matches Single crime scene report instead of a few for the same city and type, then congratulations and disregard the word "incorrect". (Leave out the initial /*) If you figured out the query that shows the If you haven't found the right crime scene report yet, click "show solution" above, and replace the contents of the box with just the revealed command. (There's also an OR keyword, which returns rows that match any of the criteria.) The AND keyword is used to string together multiple filtering criteria so that the filtered results meet each and every one of the criteria. The WHERE clause in a query is used to filter results by specific criteria. (But until you learn the JOIN keyword, you may be surprised at what happens. * (asterisk): it is used after SELECT to grab all columns from the table Ĭolumn_name(s): to select specific columns, put the names of the columns after SELECT and use commas to separate them.įROM allows us to specify which table(s) we care about to select multiple tables, list the table names and use commas to separate them. SELECT allows us to grab data for specific columns from the database: SQL keywords are not case sensitive, but we suggest using all caps for SQL keywords so that you can easily set them apart from the rest of the query. SQL keywords are used to specify actions in your queries.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |