SQL Tutorial Flashcards

Source: http://www.w3schools.com/sql/default.asp

1
Q

What is SQL?

A

A standard language for accessing databases. It stands for Structured Query Language. It is an ANSI standard however there are different versions of the language.

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

What is ANSI?

A

American National Standards Institute

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

What things do you need to build a website that shows data from a database?

A
  1. An RDBMS database program
  2. To use a server-side scripting language like PHP or ASP
  3. To use SQL to get the data you want
  4. To use HTML/CSS
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is RDBMS?

A

Relational Database Management System.

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

Is SQL case sensitive?

A

No. SELECT is the same as select but normally SQL keywords are written in uppercase.

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

How is a SQL statement ended?

A

With a semi-colon ; Some databases require a semicolon at the end of each SQL statement. It is the standard way to separate each SQL statement in database systems that allow more than one SQL statement to be executed in the same call to the server.

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

A database contains one or more _____?

A

Tables

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

A table is identified by a _____?

A

Name

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

How would you select all records in a table called “Customers” ?

A

SELECT * FROM Customers;

Pay attention to syntax!

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

What are the 11 “Most Important SQL Commands?”

A

SELECT
UPDATE
DELETE
INSERT INTO
CREATE DATABASE
ALTER DATABASE
CREATE TABLE
ALTER TABLE
DROP TABLE
CREATE INDEX
DROP INDEX

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

What does SELECT do?

A

extracts data from a database

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

What does UPDATE do?

A

updates data in a database

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

What does DELETE do?

A

deletes data (rows) from a database

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

What does INSERT INTO do?

A

inserts new records into a database

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

What does CREATE DATABASE do?

A

creates a new database

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

What does ALTER DATABASE do?

A

modifies a database

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

What does CREATE TABLE do?

A

creates a new table

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

What does ALTER TABLE do?

A

modifies a table

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

What does DROP TABLE do?

A

deletes a table

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

What does CREATE INDEX do?

A

creates an index (search key)

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

What does DROP INDEX do?

A

deletes an index

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

What statement creates a new table?

A

CREATE TABLE

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

What statement deletes a table?

A

DROP TABLE

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

What statement creates a search key?

A

CREATE INDEX

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

What statement deletes data from a database?

A

DELETE

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

What statement extracts data from a database?

A

SELECT

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

What statement updates data in a database?

A

UPDATE

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

What statement inserts new data?

A

INSERT INTO

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

What statement deletes an index?

A

DROP INDEX

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

What statement creates a database?

A

CREATE DATABASE

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

What statement modifies a table?

A

ALTER TABLE

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

What statement modifies a database?

A

ALTER DATABASE

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

What happens to the data from a SELECT statement?

A

The results are stored in a result table, called the result-set.

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

What is the complete syntax for a SELECT statement?

A

SELECT column_name, column_name
FROM table_name;

and

SELECT * FROM table_name;

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

What is the statement to select the CustomerName and City columns from the Customers table?

A

SELECT CustomerName, City
FROM Customers;

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

What does

SELECT * FROM Customers;

do?

A

It selects all columns from the Customers table.

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

How do you navigate within a result set?

A

Most database systems allow navigation in the result-set with programming functions, like: Move-To-First-Record, etc. Programming functions like these are not part of this SQL tutorial. To learn about accessing data with function calls they have ASP and PHP tutorials.

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

How do you return only different values? What example was used on the “Customer” table?

A

SELECT DISTINCT

SELECT DISTINCT City FROM Customers;

It returns a list of cities in the Customer table, but only once, even if several customers are in the same city.

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

How do you filter records? What is the syntax?

A

WHERE

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
40
Q

How would you find customers in the database who are in Mexico? Remember all the syntax.

A

SELECT * FROM Customers

WHERE Country=’Mexico’;

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

How are text fields and numeric fields handled differently?

A

SQL requires single quotes around text values (e.g. Country=’Mexico’). Most databases will allow double quotes.

Numeric field values should not be enclosed in quotes (e.g. CustomerID=1)

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

What 9 operators can be used in the WHERE clause?

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

If you have more than one condition what are the available operators and what do they mean?

A

The AND operator displays a record if both the first condition AND the second condition are true.

The OR operator displays a record if either the first condition OR the second condition is true.

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

How would you select customers from only the Berlin in Germany? Remember syntax.

A

SELECT * FROM Customers

WHERE Country=’Germany’ AND City=’Berlin’;

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

How would you select customers that are either in Berlin or Munchen?

A

SELECT * FROM Customers

WHERE City=’Berlin’ OR City=’Munchen’;

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

How would you select customers that are in Germany and either in Berlin or Munchen? (No Berlins or Munchens outside of Germany)

A

SELECT * FROM Customers

WHERE Country=’Germany’ AND (City=’Berlin’ OR City=’Munchen’);

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

What keyword sorts the result-set?

A

ORDER BY

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

What is the default order?

A

ORDER By sorts records in ascending order by default.

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

How do you sort in descending order?

A

DESC keyword

50
Q

ORDER BY syntax

A

SELECT column_name, column_name
FROM table_name
ORDER BY column_name ASC|DESC, column_name ASC|DESC;

There need not be more than one column to sort by.

51
Q

How would you order Customers by Country?

A

SELECT * FROM Customers

ORDER BY Country;

52
Q

How would you order Customers by Country, descending?

A

SELECT * FROM Customers

ORDER BY Country DESC;

53
Q

How would you order Customers by Country and CustomerName?

A

SELECT * FROM Customers

ORDER BY Country, CustomerName;

54
Q

How would you order Customers by Country ascending and CustomerName descending?

A

SELECT * FROM Customers

ORDER BY Country ASC, CustomerName DESC;

55
Q

What is the first form of INSERT INTO?

A

The first form does not specify the column names where the data will be inserted, only their values.

INSERT INTO table_name
VALUES (value1, value2, value3,…);

56
Q

What is the second form of INSERT INTO?

A

The second form specifies both the column names and the values to be inserted:

INSERT INTO table_name (column1, column2, column3,…)
VALUES (value1, value2, value3,…);

This is used to insert data only in specific columns.

57
Q

How would you add
CustomerName Cardinal,
City Stavanger
and Country Norway as a new record?

Remember syntax.

A

INSERT INTO Customers (CustomerName, City, Country)
VALUES (‘Cardinal’, ‘Stavanger’, ‘Norway’);

58
Q

If you insert values into a new record but only some of the columns, what happens to the other columns you didn’t add anything to?

A

They are null.

59
Q

What is the syntax for an UPDATE?

A

UPDATE table_name
SET column1=value1, column2=value2,…
WHERE some_column=some_value;

60
Q

What is a big gotcha in UPDATE and what happens?

A

If you forget the WHERE clause which specifies which record should be updated, all records will be updated (all their data will be overwritten with this data).

61
Q

To reiterate
What are the three parts of an UPDATE?

A

UPDATE SET WHERE

Don’t forget the WHERE part!

62
Q

How would you update the

CustomerName is Alfreds Futterkiste
with a new ContactName and City (Alfred Schmidt and Hamburg)?

A

UPDATE Customers

SET ContactName=’Alfred Schmidt’, City=’Hamburg’

WHERE CustomerName=’Alfreds Futterkiste’;

63
Q

What is the syntax for DELETE?

A

DELETE FROM table_name
WHERE some_column=some_value;

This deletes rows in a table.

64
Q

How do you delete the customer “Alfreds Futterkiste” from the “Customers” table?

A

DELETE FROM Customers

WHERE CustomerName=’Alfreds Futterkiste’;

65
Q

How would you delete all data from a table without deleting the table?

A

DELETE FROM table_name;

or

DELETE * FROM table_name;

You cannot undo this!

66
Q

An SQL Injection can ….

A

destroy your database. It is a danger in using user input in SQL statements. Injected SQL commands can alter SQL statements and compromise the security of a web application. Malicious users can inject SQL commands into a SQL statement, via web page input.

67
Q

What does this do?

txtUserId = getRequestString(“UserId”);

txtSQL = “SELECT * FROM Users WHERE UserId = “ + txtUserId;

A

This example is server code that creates a select statement by adding a variable (txtUserID) to a select string. The variable is fetched from user input (Request) to the page.

68
Q

What happens if a hacker inputs

105 or 1=1

into an input field for UserID ?

A

The server code result in this example would yield

SELECT * FROM Users
WHERE UserId = 105 or 1=1.

Since 1=1 is always true it will return all rows (all data from all rows since it’s *). If this was a table with UserID, Name and Passwords it would return all that data. (Remember or is the same as OR since most dbs are not case sensitive and we just capitalize keywords as a best practice).

69
Q

What statement using = is always true and can be used to create valid SQL that returns all data?

A

””=”” is always true. (2 double quotes, =, 2 double quotes)

So if this was put into a username and password field it would return all rows since WHERE ‘’”=”” is always true.

70
Q

How can batched SQL statements be exploited?

A

Most databases support batched SQL statements, separated by a semicolon. An example would be if someone inputted this into the User Id field on the website

105; DROP TABLE Suppliers

It could create valid code like this

SELECT * FROM Users WHERE UserId = 105; DROP TABLE Suppliers

This would return UserID 105 and then proceed to “next statement” which would delete the table Suppliers. (Presumably it’s OK that there is no semi-colon at the end since there’s not another statement to separate this from)

71
Q

What are blacklists and why are they not a great idea?

A

Some web developers create a blacklist of words or characters to search for in SQL input to prevent SQL injection attacks. However many of these words (like delete or drop) and characters (like semicolons and quotation marks) are used in common language and have legitimate uses and should be allowed in many types of input. Also, it should be legal to input an SQL statement in a database field.

72
Q

What is the only proven way to protect a website from SQL injection attacks?

A

SQL parameters

They are values added to an SQL query at execution time, in a controlled manner. The SQL engine checks each parameter to ensure that it is correct for its column and are treated literally, and not as part of the SQL to be executed. See tutorial for examples.

73
Q

How do you specify the number of records to return and why do you need to? How does each database do this?

A

SELECT TOP

This can be useful on large tables with thousands of records because returning a large number of records can impact performance.

SQL Server/MS Access Syntax
SELECT TOP number | percent column_name(s)
FROM table_name;

Equivalents

MySQL Syntax (note, it does not use the word TOP)
SELECT column_name(s)
FROM table_name LIMIT number;

Oracle Syntax
SELECT column_name(s)
FROM table_name WHERE ROWNUM <= number;

74
Q

Give 2 examples in SQL Server syntax to

1) select the first 2 records
* and then*
2) the first 50%.

A

SELECT TOP 2 * FROM Customers;

SELECT TOP 50 PERCENT * FROM Customers;

75
Q

How do you search for a specified pattern in a column?

A

LIKE

SELECT column_name(s)

FROM table_name

WHERE column_name LIKE pattern;

76
Q

How do you select all customers in a City starting with the letter “s”?

A

’s%’

SELECT * FROM Customers
WHERE City LIKE ‘s%’;

77
Q

How do you select all customers in a City ending with the letter “s”?

A

‘%s’ SELECT * FROM Customers

WHERE City LIKE ‘%s’;

78
Q

How do you select all customers in a City containing “land”?

A

‘%land%’

SELECT * FROM Customers

WHERE Country LIKE ‘%land%’;

79
Q

How do you select all customers in a City that does not contain “land”?

A

NOT LIKE

SELECT * FROM Customers

WHERE Country NOT LIKE ‘%land%’;

80
Q

When are wildcards used in SQL?

A

With the LIKE operator, to define a pattern to search for data within a table.

81
Q

What wildcard substitutes for a single character?

A

_ (underscore)

82
Q

What wildcard substitutes for zero or more characters?

A

%

83
Q

How do you search for a set and range of characters to match?

A

[charlist]

84
Q

How do you match only a character NOT specified?

A

[^charlist] or [!charlist]

Matches only a character NOT specified in the charlist.

85
Q

Select all customers with a City starting with “ber”.

A

SELECT * FROM Customers

WHERE City LIKE ‘ber%’;

86
Q

Select all customers with a city containing “es”.

A

SELECT * FROM Customers

WHERE City LIKE ‘%es%’;

87
Q

Select all customers with a city starting with any letter followed by “erlin”.

A

SELECT * FROM Customers

WHERE City LIKE ‘_erlin’;

88
Q

Select all customers in a city starting with L, then any character, then n, then any character, then on.

A

SELECT * FROM Customers

WHERE City LIKE ‘L_n_on’;

89
Q

Customers with a city starting with a b, s or p

A

SELECT * FROM Customers

WHERE City LIKE ‘[bsp]%’;

90
Q

Customers with a city starting with a, b, c or d

A

SELECT * FROM Customers

WHERE City LIKE ‘[a-d]%’;

(this is using range)

91
Q

Customers with a city NOT starting with a b, s or p - 2 ways

A

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

or

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

92
Q

What does the IN operator do and what is the syntax?

A

The IN operator allows you to specify multiple values in a WHERE clause.

SELECT column_name(s)
FROM table_name
WHERE column_name IN (value1,value2,…);

93
Q

select all customers with a City of “Paris” or “London” without using OR

A

SELECT * FROM Customers
WHERE City IN (‘Paris’,’London’);

94
Q

What is BETWEEN and what is the syntax?

A

The BETWEEN operator selects values within a range. The values can be numbers, text, or dates.

SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value1 AND value2;

95
Q

select all products with

1) a price between 10 and 20
2) a price not between 10 and 20

A

SELECT * FROM Products
WHERE Price BETWEEN 10 AND 20;

SELECT * FROM Products
WHERE Price NOT BETWEEN 10 AND 20;

96
Q

select all products with a price between 10 and 20, unless they are in CategoryID of 1,2, or 3, without using a [charlist] or CategoryID <>.

A

SELECT * FROM Products
WHERE (Price BETWEEN 10 AND 20)
AND NOT CategoryID IN (1,2,3);

97
Q

Select all products with a ProductName beginning with any of the letter between C and M without using LIKE.

A

SELECT * FROM Products
WHERE ProductName BETWEEN ‘C’ AND ‘M’;

syntax!

Yes, I know it’s weird that this works for the first letter but that’s how text BETWEEN works.

98
Q

Sselect all products with a ProductName beginning with any of the letter not between C and M

A

SELECT * FROM Products
WHERE ProductName NOT BETWEEN ‘C’ AND ‘M’;

99
Q

Select all orders with an OrderDate between 04-July-1996 and 09-July-1996

A

SELECT * FROM Orders
WHERE OrderDate BETWEEN #07/04/1996# AND #07/09/1996#;

100
Q

How can databases vary in how they evaluate BETWEEN?

A

Notice that the BETWEEN operator can produce different result in different databases!
In some databases, BETWEEN selects fields that are between and excluding the test values.
In other databases, BETWEEN selects fields that are between and including the test values.
And in other databases, BETWEEN selects fields between the test values, including the first test value and excluding the last test value.

Therefore: Check how your database treats the BETWEEN operator!

101
Q

What are aliases and what is the syntax?

A

SQL aliases are used to give a database table, or a column in a table, a temporary name. Basically aliases are created to make column names more readable.

SQL Alias Syntax for Columns

SELECT column_name AS alias_name
FROM table_name;

SQL Alias Syntax for Tables

SELECT column_name(s)
FROM table_name AS alias_name;

102
Q

Select from the following columns and specifie two aliases, one for the CustomerName (Customer) column and one for the ContactName (Contact Person) column from the Customers table.

A

SELECT CustomerName AS Customer, ContactName AS [Contact Person]
FROM Customers;

Tip: It requires double quotation marks or square brackets if the column name contains spaces:

103
Q

Select CustomerName and also combine four columns (Address, City, PostalCode, and Country) and create an alias named “Address” from the Customer table.

A

SELECT CustomerName, Address+’, ‘+City+’, ‘+PostalCode+’, ‘+Country AS Address
FROM Customers;

or for MySQL

SELECT CustomerName, CONCAT(Address,’, ‘,City,’, ‘,PostalCode,’, ‘,Country) AS Address
FROM Customers;

104
Q

Select all the orders from the customer with CustomerID=4 (Around the Horn). We use the “Customers” and “Orders” tables, and give them the table aliases of “c” and “o” respectively (Here we have used aliases to make the SQL shorter)

columns in Orders - OrderID, OrderDate
column in Customers - CustomerName

A

SELECT o.OrderID, o.OrderDate, c.CustomerName
FROM Customers AS c, Orders AS o
WHERE c.CustomerName=”Around the Horn” AND c.CustomerID=o.CustomerID;

Done without aliases

SELECT Orders.OrderID, Orders.OrderDate, Customers.CustomerName
FROM Customers, Orders
WHERE Customers.CustomerName=”Around the Horn” AND Customers.CustomerID=Orders.CustomerID;

105
Q

Aliases can be useful when…(4 points)

A
  • There are more than one table involved in a query
  • Functions are used in the query
  • Column names are big or not very readable
  • Two or more columns are combined together
106
Q

What are joins and what is the syntax for the most common type?

A

SQL joins are used to combine rows from two or more tables.

An SQL JOIN clause is used to combine rows from two or more tables, based on a common field between them.

The most common type of join is: SQL INNER JOIN (simple join). An SQL INNER JOIN return all rows from multiple tables where the join condition is met.

SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name=table2.column_name;

107
Q

What is an INNER JOIN?

A

Returns all rows when there is at least one match in BOTH tables.

Note: INNER JOIN is the same as JOIN

108
Q

What is a LEFT JOIN?

A

Return all rows from the left table, and the matched rows from the right table

109
Q

What is a RIGHT JOIN?

A

Return all rows from the right table, and the matched rows from the left table

110
Q

What is a FULL JOIN?

A

Return all rows when there is a match in ONE of the tables

111
Q

What does the inner join look like diagrammed?

A
112
Q

Return all customers with orders (their names and their order id) from the Customers and Orders tables and sort it by name.

A

SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
INNER JOIN Orders
ON Customers.CustomerID=Orders.CustomerID
ORDER BY Customers.CustomerName;

113
Q

Explain LEFT JOIN and syntax.

A

The LEFT JOIN keyword returns all rows from the left table (table1), with the matching rows in the right table (table2). The result is NULL in the right side when there is no match. In some databases LEFT JOIN is called LEFT OUTER JOIN.

SELECT column_name(s)
FROM table1
LEFT JOIN table2
ON table1.column_name=table2.column_name;

or

SELECT column_name(s)
FROM table1
LEFT OUTER JOIN table2
ON table1.column_name=table2.column_name;

114
Q

What does a LEFT JOIN look like in the diagram?

A
115
Q

How would you use LEFT JOIN to return all customers and any orders they might have?

A

SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
LEFT JOIN Orders
ON Customers.CustomerID=Orders.CustomerID
ORDER BY Customers.CustomerName;

The LEFT JOIN keyword returns all the rows from the left table (Customers), even if there are no matches in the right table (Orders).

116
Q

What is RIGHT JOIN and what is the syntax?

A

The RIGHT JOIN keyword returns all rows from the right table (table2), with the matching rows in the left table (table1). The result is NULL in the left side when there is no match. In some databases RIGHT JOIN is called RIGHT OUTER JOIN.

SELECT column_name(s)
FROM table1
RIGHT JOIN table2
ON table1.column_name=table2.column_name;

or

SELECT column_name(s)
FROM table1
RIGHT OUTER JOIN table2
ON table1.column_name=table2.column_name;

117
Q

What does a RIGHT JOIN or RIGHT OUTER JOIN look like?

A
118
Q

Return all employees, and any orders they have placed using a RIGHT JOIN.

A

SELECT Orders.OrderID, Employees.FirstName
FROM Orders
RIGHT JOIN Employees
ON Orders.EmployeeID=Employees.EmployeeID
ORDER BY Orders.OrderID;

The RIGHT JOIN keyword returns all the rows from the right table (Employees), even if there are no matches in the left table (Orders).

119
Q

What is a FULL OUTER JOIN and what is the syntax?
What does it look like?

A

The FULL OUTER JOIN keyword returns all rows from the left table (table1) and from the right table (table2).

The FULL OUTER JOIN keyword combines the result of both LEFT and RIGHT joins.

SELECT column_name(s)
FROM table1
FULL OUTER JOIN table2
ON table1.column_name=table2.column_name;

120
Q

Select all customers, and all orders using a FULL OUTER JOIN.

A

SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
FULL OUTER JOIN Orders
ON Customers.CustomerID=Orders.CustomerID
ORDER BY Customers.CustomerName;

Note: The FULL OUTER JOIN keyword returns all the rows from the left table (Customers), and all the rows from the right table (Orders). If there are rows in “Customers” that do not have matches in “Orders”, or if there are rows in “Orders” that do not have matches in “Customers”, those rows will be listed as well. Result may look like this…

CustomerName OrderID

Alfreds Futterkiste
Ana Trujillo Emparedados y helados 10308
Antonio Moreno Taquería 10365
10382
10351

121
Q

Start here http://www.w3schools.com/sql/sql_union.asp

A

answer answer