Joins and Statements Flashcards
inner join
pulls together data with matching entry from two tables; excludes data without matching entry
left join
shows full left table with records that match from the right table; excludes non-matching records from right table
right join
shows full right table with records that match from the left table; excludes non-matching records from left table
full outer join
shows both tables’ matched as well as unmatched entries
select
extracts data;
select (* or column)
where “a condition is present”
from
a place, usually a table name
where
used to extract only records that fulfill specific criteria;
SELECT column_name,column_name
FROM table_name
WHERE column_name operator value;
update
updates data;
update “tablename”
set “columntochange” = “desired value”
where “a condition is present”
insert into
inserts new data;
insert into “table” -then blank if entries are in order, if not then (“column1”,”column3”),etc)
values (‘varchar’,int, etc)
delete
deletes data; delete from (table or db) where "condition"
select distinct
returns only distinct values;
select distinct followed by normal query
order by
sorts the result of a query;
select
from
order by “column_name” asc or desc
like
used with wildcards to search for specified patterns in a column
*
brings everything from the selection
%
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%’;