our approach
|
new tutorials
|
contact us
MySQL Basics In Pictures
Starting
Administration
Tables
Queries
Security
Web
Type:
SELECT quote,last FROM quote,name WHERE (quote.name_id=name.id AND last='Jefferson');
then press
ENTER
.
The query results should look like this:
This query joins the two tables
quote
and
name
, but you're using different criteria in the
WHERE
statement:
WHERE (quote.name_id=name.id AND last='Jefferson')
The first condition is the same as before:
quote.name_id=name.id
name_id
(in the
quote
table) and
id
(in the
name
table) are the link between the two tables.
The second condition:
last='Jefferson'
narrows the query to only those quotes from presidents with the last name of Jefferson.
The single quotes surrounding
'Jefferson'
tell the database that
Jefferson
is text.
TIP:
If you use numeric criteria in your query, don't use quotes. For instance, you'd type:
SELECT quote,last FROM quote,name WHERE (quote.name_id=name.id AND name.id=2);
<< BACK
NEXT >>