Joins and Statements Flashcards

1
Q

inner join

A

pulls together data with matching entry from two tables; excludes data without matching entry

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

left join

A

shows full left table with records that match from the right table; excludes non-matching records from right table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

right join

A

shows full right table with records that match from the left table; excludes non-matching records from left table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

full outer join

A

shows both tables’ matched as well as unmatched entries

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

select

A

extracts data;
select (* or column)
where “a condition is present”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

from

A

a place, usually a table name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

where

A

used to extract only records that fulfill specific criteria;
SELECT column_name,column_name
FROM table_name
WHERE column_name operator value;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

update

A

updates data;
update “tablename”
set “columntochange” = “desired value”
where “a condition is present”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

insert into

A

inserts new data;
insert into “table” -then blank if entries are in order, if not then (“column1”,”column3”),etc)
values (‘varchar’,int, etc)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

delete

A
deletes data;
delete from (table or db)
where "condition"
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

select distinct

A

returns only distinct values;

select distinct followed by normal query

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

order by

A

sorts the result of a query;
select
from
order by “column_name” asc or desc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

like

A

used with wildcards to search for specified patterns in a column

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

*

A

brings everything from the selection

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

%

A

substitutes for zero or more characters eg: to search for cities that start with “S”
SELECT * FROM Customers
WHERE City LIKE ‘s%’

ending with the letter “S”:

SELECT * FROM Customers
WHERE City LIKE ‘%s’

where the customers country contains “land”:

SELECT * FROM Customers
WHERE Country LIKE ‘%land%’

and where the country doesn’t contain “land”:

SELECT * FROM Customers
WHERE Country NOT LIKE ‘%land%’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

_

A

substitutes for 1 character

17
Q

[]

A

sets and ranges of characters to match eg: this statement selects all customers with a city starting with b, s, or p
SELECT * FROM Customers
WHERE City LIKE ‘[bsp]%’

or

SELECT * FROM Customers
WHERE City LIKE ‘[a-c]%’

selects all customers with a City NOT starting with “b”, “s”, or “p”

SELECT * FROM Customers
WHERE City LIKE ‘[!bsp]%’

or

SELECT * FROM Customers
WHERE City NOT LIKE ‘[bsp]%’

18
Q

!

A

“does not equal” or “not”; used with wildcards

19
Q

truncate table

A

deletes a table inside a database eg:

TRUNCATE TABLE table_name