Monday, 29 August 2016

Use Text



Until now, we only worked with numbers in our WHERE clauses. Is it possible to put letters in their place? Of course it is! Just remember to put your text 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' is different than 'SMITH'.




Syntax
SELECT * FROm table_name WHERE column_name='value';
Exercise

Select all columns of all Ford cars from the table.

select vin, brand, model, price, production_year from car WHERE brand='Ford';


VIN
BRAND
MODEL
PRICE
PRODUCTION_YEAR
LJCPCBLCX14500264
Ford
Focus
8000.00
2005
WPOZZZ79ZTS372128
Ford
Fusion
12500.00
2008

No comments:

Post a Comment