MySQL Query Lab I 25 Points

186
1 MySQL Query Lab I 25 Points MySQL TU Database Dr. Thomas Hicks

description

MySQL Query Lab I 25 Points. MySQL TU Database Dr. Thomas Hicks . You May Do This Lab On Your Own Personal Computer Or On Your Database System. Your Name _________________ Name This Presentation: Tom-Hicks-MySQL-Query-1.pptx {Substitute Your First & Last Names}. Computer Used Is - PowerPoint PPT Presentation

Transcript of MySQL Query Lab I 25 Points

Page 1: MySQL Query Lab I 25 Points

1

MySQL Query Lab I25 Points

MySQLTU Database

Dr. Thomas Hicks

Page 2: MySQL Query Lab I 25 Points

2

You May Do This Lab On Your

Own Personal Computer Or On Your Database

System

Page 3: MySQL Query Lab I 25 Points

Your Name

_________________

Name This Presentation:Tom-Hicks-MySQL-Query-1.pptx

{Substitute Your First & Last Names}

Page 4: MySQL Query Lab I 25 Points

Computer Used Is

_________________

{My Personal Computer or CS-??}

Page 5: MySQL Query Lab I 25 Points

5

Your Slide Presentation Should

Include Screen Captures That Are Cropped – Clear &

Easy To Read

Page 6: MySQL Query Lab I 25 Points

6

If This Bar Is Light Blue – It Is Info That You Should Read!

Helpful HintThere Will Often Be A Colored Title Bar At The Top Of A Slide

If This Bar Is Red – You Will Have Screen Captures To Replicate And/Or Questions To Answer

If This Bar Is Green – You Will Have To Create Original Screen Captures And/Or Questions To Answer

Page 7: MySQL Query Lab I 25 Points

7

Use The Snippping Tool To Help You With Your Screen Captures

Use Both The Rectangular Snip & The Window Snip As Is Appropriate!

Page 8: MySQL Query Lab I 25 Points

8

Trying To Capture SHOW FIELDS Command:

Good!

Page 9: MySQL Query Lab I 25 Points

9

Use Good/Neat/Readable Captures Crop Your CapturesDon’t Include Extraneous Stuff! This Is Not Good!

BAD!

Page 10: MySQL Query Lab I 25 Points

10

Use The MySQL Command Line

Client

Answer All QuestionsReplace Screen Captures

Page 11: MySQL Query Lab I 25 Points

The Basics Of SQL Are Generic

Many Implementations Of MySQL Offer Additional Enhancements

(i.e. MySQL Might Have A String Function, Or Mathematical Function, That Might Not Be

Available In MSSQL)

You Can Generally Add Your Own Custom Functions To Most SQL Environments.

Page 12: MySQL Query Lab I 25 Points

12

SQL

Structured Query Language

Page 13: MySQL Query Lab I 25 Points

13

SQL?

SQL is an acronym for

_____________________________________________________

Page 14: MySQL Query Lab I 25 Points

14

MySQL

Fully Relalational Database

Free Community VersionAvailable

Page 15: MySQL Query Lab I 25 Points

15

Starting MySQL In The LabsOpen A CMD Window

Page 16: MySQL Query Lab I 25 Points

16

Starting MySQL In The LabsOn Your Computer

Replace The Bottom Screen Capture With Yours

Page 17: MySQL Query Lab I 25 Points

17

Open MySQL Command Line ClientReplace The Capture Below!

We Are Using MySQL Server Version _?_ {4.4.3-beta below}

Page 18: MySQL Query Lab I 25 Points

18

Put FileLibrary-Hicks

On Your Desktop

Page 19: MySQL Query Lab I 25 Points

19

Put File Library-Hicks.sql On Your DesktopShow The Size In General Properties

Replace The Capture Below!

Page 20: MySQL Query Lab I 25 Points

20

HELP

List MySQL Commands

Page 21: MySQL Query Lab I 25 Points

21

Display The MySQL CommandsReplace The Capture Below!

Page 22: MySQL Query Lab I 25 Points

22

Configure MySQL

CommandWindow

Page 23: MySQL Query Lab I 25 Points

23

Getting Ready To Change Window Properties

Using the mouse, Right Mouse Click On The Top Of The Window and Select Properties

Page 24: MySQL Query Lab I 25 Points

24

Set The Window Screen Text To WhiteSet Your Background To Red, Black, Green, Or Navy

Do Not Select Maroon Background

Page 25: MySQL Query Lab I 25 Points

25

Set The Window Properties As Illustrated BelowReplace The Capture Below!

Page 26: MySQL Query Lab I 25 Points

26

Set The Window Screen Text To WhiteSet The Background To Red, Black, Green, Or Navy

Do Not Select Maroon Background

Page 27: MySQL Query Lab I 25 Points

27

CREATE DATABASE

Library??

Replace ?? With Your Initials

Page 28: MySQL Query Lab I 25 Points

28

Create Database Library?? [Replace ?? With Your Initials]

Show All Databases On Your SystemReplace The Capture Below!

Page 29: MySQL Query Lab I 25 Points

29

Restore Library Database

Using MySQL

WorkBench

Page 30: MySQL Query Lab I 25 Points

30

Start MySQL WorkBench

Page 31: MySQL Query Lab I 25 Points

31

Push The New Connection Link In SQL Development

Page 32: MySQL Query Lab I 25 Points

32

Enter localhost Push Store In Vault Button

Page 33: MySQL Query Lab I 25 Points

33

Enter The Root Password!

Page 34: MySQL Query Lab I 25 Points

34

Push The Test Connection Button

Page 35: MySQL Query Lab I 25 Points

35

If Connection OK Push The OK Button

Page 36: MySQL Query Lab I 25 Points

36

Double-Click On connection (localhost)

Page 37: MySQL Query Lab I 25 Points

37

Open The Script File

Page 38: MySQL Query Lab I 25 Points

38

Select Library-Hicks.sql From The Desktop

Page 39: MySQL Query Lab I 25 Points

39

Double-Click On connection (localhost)

Page 40: MySQL Query Lab I 25 Points

40

Save The Script To File

Page 41: MySQL Query Lab I 25 Points

41

Refresh – Right Mouse Click – Schemas/Databases

Page 42: MySQL Query Lab I 25 Points

42

You Should Have Database LibraryTH

Page 43: MySQL Query Lab I 25 Points

43

Change The 3 References To LibraryTHTo Library?? Where ?? Are Your Initials

Page 44: MySQL Query Lab I 25 Points

44

Doug Wolf Would Make The Following ChangesExecute & Save & Refresh

Page 45: MySQL Query Lab I 25 Points

45

It Is That Easy To Make Test Copy Of A DatabaseFrom The .sql Backup File

Page 46: MySQL Query Lab I 25 Points

46

All Of The Fields In Your Database Will Match Those In My Database 100%

I Reserve The Right To Use Slightly Different Data In An Effort To Ensure That You Carefully Examine Your Own Queries!

All Of The Relationships In Your Database Will Match Those In My Database 100%

All Of The Table & Field Names Will Match 100%

Page 47: MySQL Query Lab I 25 Points

47

A Database Is More Than A Collection Of Tables

Tables, Programs, Indexes, Views, Forms, Reports, Relationships,

Etc.

Page 48: MySQL Query Lab I 25 Points

48

Definitions of Database on the Web:A database is an organized body of related information wordnetweb.princeton.edu/perl/webwn

A database is a structured collection of records or data that is stored in a computer system. The structure is achieved by organizing the data ...en.wikipedia.org/wiki/Database

A database is a systematically arranged collection of computer data, structured so that it can be automatically retrieved or manipulatedvalidwebdesigns.com/glossary/

A database is a collection of data organized for search and retrieval.summitschool.com/8review/dbssterms.doc

A collection of interrelated data items stored together without unnecessary redundancy, to serve one or more applications.www.4pcb.com/index.php

Page 49: MySQL Query Lab I 25 Points

49

USE … (Database)

Open A Database

The Open Database Is Often Called The Default Database

Page 50: MySQL Query Lab I 25 Points

50

Show All Databases On Your System. Open Your Library?? Database. Only One Database May Be Open At A Time.

Replace The Capture Below!

Page 51: MySQL Query Lab I 25 Points

51

SHOW TABLESSHOW TABLES IN ...(Database)

Show Tables (Open Database)

Page 52: MySQL Query Lab I 25 Points

52

Show The Commands To: Show All Tables In The Open Database

Replace The Capture Below!

Page 53: MySQL Query Lab I 25 Points

53

1] Open Your Library?? Database2] Display The Tables The MySQL Database Without Opening It

Replace The Capture Below!

The MySQL Database contains information about Databases, Tables, Users, Permissions, etc. Although you could alter it with the superuser (root) account, it is quite easy to destroy your MySQL system in the process! Don’t Change The MySQL Database!

Page 54: MySQL Query Lab I 25 Points

54

DESCRIBE …. (Table) SHOW FIELDS IN …. (Table)

Display TheDatabase Table Layout

(Fields, DataTypes, Etc.)

Page 55: MySQL Query Lab I 25 Points

55

1] Open Your Library?? Database2] Display The Tables In The Open Database3] Show The Table Layout For Authors Replace The Capture Below!

Page 56: MySQL Query Lab I 25 Points

56

1] Show A Table Listing For Authors Two Different Ways Replace The Capture Below!

Page 57: MySQL Query Lab I 25 Points

57

1] Show A Table Listing For Servers Two Different Ways Include The Capture Below!

Page 58: MySQL Query Lab I 25 Points

58

Users Table

Page 59: MySQL Query Lab I 25 Points

59

A Graphical View Of Table UsersThe Table Layout May Be Seen Below!

Page 60: MySQL Query Lab I 25 Points

60

Show Table Layout (Fields)

Page 61: MySQL Query Lab I 25 Points

61

1] Show A Table Layout For Users Replace The Capture Below!

Page 62: MySQL Query Lab I 25 Points

62

Simple

SELECT * FROM … (Table(s))

Page 63: MySQL Query Lab I 25 Points

63

1] Display All Of The Information About All Of The Users Replace The Capture Below!

Page 64: MySQL Query Lab I 25 Points

64

SELECT …. First Line

FROM … Next Line

WHERE … Next Line If There

ORDER BY … Next Line If There

Use The Document Query Format For All Slides!

Document Query Format

Page 65: MySQL Query Lab I 25 Points

65

SELECT … (Fields) FROM … (Table(s))

Page 66: MySQL Query Lab I 25 Points

66

1] Display The First, Last, & Email Of All Of The Users Replace The Capture Below!

Page 67: MySQL Query Lab I 25 Points

67

1] Display The FullName, Phone, & Email Of All Of The Users Include The Screen Capture Below!

Page 68: MySQL Query Lab I 25 Points

68

1] Display The FullName, UserName, & Email Of All Of The Users Include The Screen Capture Below!

Page 69: MySQL Query Lab I 25 Points

69

SELECT … (Fields)

FROM … (Table(s))

WHERE … (Conditions)

Conditional Operators>, <, <>, >=, <=, =, !=

Between

Page 70: MySQL Query Lab I 25 Points

70

1] Display The ID, First, Last, & Email Of All Of The Users Whose ID Is Greater Than Or Equal To 5 Replace The Capture Below!

Page 71: MySQL Query Lab I 25 Points

71

1] Display The ID, First, Last, & Email Of All Of The Users Whose ID Is Less Than Or Equal To 3 Include The Screen Capture Below!

Page 72: MySQL Query Lab I 25 Points

72

1] Display The ID, First, Last, & Email Of All Of The Users Whose ID Is Equal To 2 Replace The Capture Below!

Page 73: MySQL Query Lab I 25 Points

73

SELECT … (Fields)FROM … (Table(s))

WHERE … (Conditions)

AND, OR, NOT

&&, ||, !

Page 74: MySQL Query Lab I 25 Points

74

1] Display The ID, First, Last, & Email Of All Of The Users Whose ID Is In The Range 7 to 9 (Three Different Ways)

Replace The Capture Below!

Page 75: MySQL Query Lab I 25 Points

75

1] Display The ID, First, Last, & Email Of All Of The Users Whose ID Is In The Range 13 to 15 (Three Different Ways)

Include Screen Capture Below!

Page 76: MySQL Query Lab I 25 Points

76

1] Display The ID, First, Last, & Email Of All Of The Users Whose ID Is Not Equal To 5 Replace The Capture Below!

Page 77: MySQL Query Lab I 25 Points

77

1] Display The ID, First, Last, & Email Of All Of The Users Whose ID Is Not Equal To 1 Include The Capture Below!

Page 78: MySQL Query Lab I 25 Points

78

1] Display The ID, First, Last, & Email Of All Of The Users Whose ID Is Not Equal To 5. Do Not Use <> Replace The Capture Below!

Page 79: MySQL Query Lab I 25 Points

79

1] Display The ID, First, Last, & Email Of All Of The Users Whose ID Is Not Equal To 5. Do Not Use <> Or != Replace The Capture Below!

Page 80: MySQL Query Lab I 25 Points

80

1] Display The ID, First, Last, Administrator & Email Of All Of The Users Whose ID Is Not An Administrator. Include The Capture Below!

Page 81: MySQL Query Lab I 25 Points

81

1] Display The ID, First, Last, & Email Of All Of The Users Whose ID 1, 3, or 5 (Two Different Ways) Replace The Capture Below!

Page 82: MySQL Query Lab I 25 Points

82

1] Display The ID, First, Last, & Email Of All Of The Users Whose ID 2, 4, 6, or 8 (Two Different Ways) Include The Capture Below!

Page 83: MySQL Query Lab I 25 Points

83

SELECT … (Fields)FROM … (Table(s))

WHERE … (Conditions)

ORDER BY … ASC/DEC

Page 84: MySQL Query Lab I 25 Points

84

1] Display The ID, First, Last, & Email Of All Of The Users; order the data by First Name Replace The Capture Below!

Page 85: MySQL Query Lab I 25 Points

85

1] Display The ID, First, Last, & Email Of All Of The Users; order the data by Last Name Include The Screen Capture Below!

Page 86: MySQL Query Lab I 25 Points

86

1] Display The ID, First, Last, UserName, Email & FullName Of All Of The Users Whose ID Is In The Range 7 to 13; Order By FullName Replace The Capture Below!

We Would Normally Prefer Not To Order By First Or Last

Page 87: MySQL Query Lab I 25 Points

87

1] Display The ID, First, Last, UserName, Email & FullName Of All Of The Users Whose First Name Is Either “Jordan” or “JORDAN” Replace The Capture Below!

When Using The MySQL Query Language, Searching For Strings __??__ {Is/Is Not} Case

Sensitive!

Page 88: MySQL Query Lab I 25 Points

88

1] Display The ID, First, Last, UserName, Email & FullName Of All Of The Users Whose First Name Is Either ‘Jordan’ or ‘JORDAN’ Replace The Capture Below!

_____ {T/F} When Searching For Strings Using The MySQL Query Language, Strings May Be Delimited By Either Single Or Double Quotes.

_____ {T/F} When Searching For Strings Using The MySQL Query Language, A String May Begin With A Single Quote And End With A Double Quote.

Page 89: MySQL Query Lab I 25 Points

89

1] Display The ID, First, Last, UserName, Email & FullName Of All Of The Users Whose Last Name Is Wong Include The Capture Below!

Page 90: MySQL Query Lab I 25 Points

90

SELECT … (Fields)FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

LIKE … Wild Card %

Page 91: MySQL Query Lab I 25 Points

91

1] Display The ID, First, Last, UserName, Email & FullName Of All Of The Users Whose Last Name Begins With A ‘W’ Replace The Capture Below!

Page 92: MySQL Query Lab I 25 Points

92

1] Display The ID, First, Last, UserName, Email & FullName Of All Of The Users Whose Last Name Or First Name Contains ‘AN’ Replace The Capture Below!

Page 93: MySQL Query Lab I 25 Points

93

1] Display The ID, First, Last, UserName, Email & FullName Of All Of The Users Whose First Name Ends With An ‘M’ Replace The Capture Below!

Page 94: MySQL Query Lab I 25 Points

94

1] Display The ID, First, Last, UserName, Email & FullName Of All Of The Users Whose Last Name Or First Name Contains An ‘O’ Include The Capture Below!

Page 95: MySQL Query Lab I 25 Points

95

1] Display The ID, First, Last, & Phone Of All Of The Users Whose Phone Number Contains Either A ‘3’ Or A ‘4’ Include The Capture Below!

Page 96: MySQL Query Lab I 25 Points

96

SELECT … (Fields)FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

UPPER(str) - UCASE(str)LOWER(str) - LCASE(str)

Page 97: MySQL Query Lab I 25 Points

97

1] Display The First, Last & Of All Of The Users; Make Sure The First And Last Name Are Capital (Upper Case) Replace The Capture Below!

Page 98: MySQL Query Lab I 25 Points

98

1] Display The First, Last & Of All Of The Users; Make Sure The First And Last Name Are Capital (Upper Case) And Email Is Non-Capital (Lower Case)Do Not Use Upper Or Lower! Replace The Capture Below!

Page 99: MySQL Query Lab I 25 Points

99

1] Display The First, Last & Of All Of The Users; Make Sure All The Fields Are Non-Capital (Lower Case) Replace The Capture Below!

Page 100: MySQL Query Lab I 25 Points

100

1] Display The String ‘tOm hICkS’ in Non-Capitals2] Display The String ‘tOm hICkS’ in Capitals3] Display The String ‘tOm hICkS’ in Non-Capitals And Capitals Replace The Capture Below!

Page 101: MySQL Query Lab I 25 Points

101

1] Display The String ‘tOm hICkS’ in Non-Capitals2] Display The String ‘tOm hICkS’ in Capitals3] Display The String ‘tOm hICkS’ in Non-Capitals And Capitals Replace The Capture Below!

Page 102: MySQL Query Lab I 25 Points

102

SELECT … (Fields)FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

NumericOrder Operations(+,-,*,/)

POW(#,#)

Page 103: MySQL Query Lab I 25 Points

103

1] Display 1232] Display 12 + 343] Display 2 * 3 + 4 * 5 Replace The Capture Below!

_____ {T/F} It Appears That MySQL Is Processing The Order Of Operations Correctly In The Examples Above.

Page 104: MySQL Query Lab I 25 Points

104

1] Display 2^32] Display 2 + 2^33] Display 2 ^3^2 Replace The Capture Below!

_____ {T/F} It Appears That MySQL Is Processing The Order Of Operations Correctly In The Examples Above.

Page 105: MySQL Query Lab I 25 Points

105

1] Display (2 * 3 / 4) * 10 – (4 / 2 + 1)2] Display 2 + 3 ^ 2 Include The Capture Below!

_____ {T/F} It Appears That MySQL Is Processing The Order Of Operations Correctly In The Examples Above.

Page 106: MySQL Query Lab I 25 Points

106

1] Display “12” + “34”2] Display “12” / 4 Replace The Capture Below!

_____ {T/F} It Appears That MySQL Automatically Converts The Character Data “12” to Numeric When Applying Mathematical Operators +, -, /, and *.

Page 107: MySQL Query Lab I 25 Points

107

SELECT … (Fields)FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

CONCAT(str,str,…)

Page 108: MySQL Query Lab I 25 Points

108

1] Display “Community” + “Baptist” + “Church” Combined2] Display First And Last Names Of All Users Combined In The Form ‘TomHicks’ Replace The Capture Below!

Page 109: MySQL Query Lab I 25 Points

109

1] Display The Last Name + “, “ + First Name Of All Users; [Hicks, Tom] Include The Capture Below!

Page 110: MySQL Query Lab I 25 Points

110

SELECT … (Fields)

FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

SUBSTRING(str,#,#)MID(str,#,#)

Page 111: MySQL Query Lab I 25 Points

111

1] Display Characters 1, 2, and 3 of ‘CBCAlamoHeights.com’2] Display Characters 4, 5, 6, 7, and 8 of ‘CBCAlamoHeights.com’3] Display Characters 17, 18, and 19 of ‘CBCAlamoHeights.com’ Replace The Capture Below!

Page 112: MySQL Query Lab I 25 Points

112

1] Display Characters 1, 2, and 3 of ‘CBCAlamoHeights.com’2] Display Characters 4, 5, 6, 7, and 8 of ‘CBCAlamoHeights.com’3] Display Characters 17, 18, and 19 of ‘CBCAlamoHeights.com’Do Not Use SubString Replace The Capture Below!

Page 113: MySQL Query Lab I 25 Points

113

1] Display The Combination of a) First Letter Of Each First Name (Lower Case)b) Last Name (Lower Case) c) “@trinity.edu”

Include The Capture Below!

Page 114: MySQL Query Lab I 25 Points

114

TRACEFILE

\T (Path:FileName)\t

Page 115: MySQL Query Lab I 25 Points

115

1] Start A Trace To File C:\Output.txt2] Display The ID, First, Last, UserName, and Email Of All User In Order By Last Name.3] Stop The Trace. Replace The Capture Below!

Page 116: MySQL Query Lab I 25 Points

116

1] Open File C:\Output.txt with Notepad. Replace The Capture Below!

Page 117: MySQL Query Lab I 25 Points

117

1] Start A Trace To File C:\Trinity.txt2] Display The ID, First, Last, Phone, and Email Of All User In Order By FullName.3] Stop The Trace. Include The Capture Below!

Page 118: MySQL Query Lab I 25 Points

118

1] Open File C:\Trinity.txt with Notepad. Include The Capture Below!

Page 119: MySQL Query Lab I 25 Points

119

SELECT … (Fields)FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

VERTICAL LISTING\G

Page 120: MySQL Query Lab I 25 Points

120

1] Display A Vertical Listing Of The First, Last, Phone, and Email Of All Users Whose ID is Greater Than Or Equal To 13 Replace The Capture Below!

Page 121: MySQL Query Lab I 25 Points

121

1] Display A Vertical Listing Of The ID, First, Last, Phone, and Email Of All Users Whose ID is Between 7 and 10 Include The Capture Below!

Page 122: MySQL Query Lab I 25 Points

122

SELECT … (Fields)FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

TRIM(str), RTRIM(str),

LTRIM(str)

Page 123: MySQL Query Lab I 25 Points

123

1] Display The Combination Of “*” + RRIM(“ Happy Days “) + “*”

2] Display The Combination Of “*” + LRIM(“ Happy Days “) + “*”

3] Display The Combination Of “*” + TRIM(“ Happy Days “) + “*”

[There Are Times That Users Accidently Place Leading And/Or Trailing Blanks In Data Input – Trim May Be Used To Remove Those Blanks]

Replace The Capture Below!

Page 124: MySQL Query Lab I 25 Points

124

SELECT … (Fields) AS ..FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

AVG(fl), SUM(fl) MAX(fl), MIN

Page 125: MySQL Query Lab I 25 Points

125

1] Display Average ID’s Of All Users;2] Display The Sum Of The ID’s Of All Users; Replace The Capture Below!

Page 126: MySQL Query Lab I 25 Points

126

1] Display Average ID’s Of All Users;2] Display The Sum Of The ID’s Of All Users;3] Display String “AVG(ID) = ??” Replace The Capture Below!

Page 127: MySQL Query Lab I 25 Points

127

1] Assign 2 * 3 to X And Display;2] Assign The Largest User ID To MAX_ID And Display; 3] ] Assign The Smallest User ID To MAX_ID And Display; Replace The Capture Below!

Page 128: MySQL Query Lab I 25 Points

128

SELECT … (Fields) AS ..FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

CHAR(#), ASCII(ch)

Page 129: MySQL Query Lab I 25 Points

129

1] Do A Goggle Search For ASCII. Display The First 127 Values. Replace The Capture Below!

Page 130: MySQL Query Lab I 25 Points

130

1] Display The Character Whose ASCII Value Is 65;2] Display The Characters Whose ASCII Value Are 32, 97, and 48; 3] Display The ASCII Value Of Character ‘A’; 4] Display The ASCII Values Of Characters ‘ ’, ‘a’, and ‘0’ Replace The Capture Below!

Page 131: MySQL Query Lab I 25 Points

131

1] Display The Character Whose ASCII Value Is 80;2] Display The Characters Whose ASCII Value Are 35, 94, and 100; 3] Display The ASCII Value Of Character ‘+’; 4] Display The ASCII Values Of Characters ‘b’, ‘c’, and ‘d’ Include The Capture Below!

Page 132: MySQL Query Lab I 25 Points

132

SELECT … (Fields) AS ..FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

CEIL(#), FLOOR(#) ROUND(#), ROUND(#,#)

Page 133: MySQL Query Lab I 25 Points

133

1] Display Floor and Ceiling of 2.51, 2.49, -2.51, 7 -2.49 Replace The Capture Below!

Page 134: MySQL Query Lab I 25 Points

134

1] Display Floor and Ceiling 123.4567 & 123.56702] Display Floor and Ceiling 1.499999, 1.50001, & 1.500 Replace The Capture Below!

Page 135: MySQL Query Lab I 25 Points

135

1] Display The Position Of ‘Maury’ In ‘Dr. Maury Eggen’; Assign It To Loc2] Display The Position Of ‘Egg’ In ‘Dr. Maury Eggen’; Assign It To Pos3] Display The Position Of ‘Dr’ In ‘Dr. Maury Eggen’; Assign It To Loc 4] Display The Position Of ‘Doc’ In ‘Dr. Maury Eggen’; Assign It To Loc Replace The Capture Below!

Page 136: MySQL Query Lab I 25 Points

136

SELECT … (Fields) AS ..FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

LEFT(str, #) RIGHT(str, #)

Page 137: MySQL Query Lab I 25 Points

137

1] Display The First 5 Characters Of The First Name and The First 7 Characters Of The Last Name. Replace The Capture Below!

Page 138: MySQL Query Lab I 25 Points

138

1] Display The Last 5 Characters Of The First Name and The Last 7 Characters Of The Last Name. Replace The Capture Below!

Page 139: MySQL Query Lab I 25 Points

139

SELECT…AS

POSITION(str, st)INSTR(str, st)

LOCATE(str, st)

Page 140: MySQL Query Lab I 25 Points

140

1] Display The Position Of ‘Maury’ In ‘Dr. Maury Eggen’; Assign It To Loc2] Display The Position Of ‘Egg’ In ‘Dr. Maury Eggen’; Assign It To Pos3] Display The Position Of ‘Dr’ In ‘Dr. Maury Eggen’; Assign It To Loc 4] Display The Position Of ‘Doc’ In ‘Dr. Maury Eggen’; Assign It To Loc Replace The Capture Below!

Page 141: MySQL Query Lab I 25 Points

141

1] Display The Position Of ‘Egg’ In ‘Dr. Maury Eggen’; Assign It To Pos Do It Three Different Ways Replace The Capture Below!

Page 142: MySQL Query Lab I 25 Points

142

1] Display First Name And The Position Of ‘A’ In The First Name For All Users Replace The Capture Below!

Page 143: MySQL Query Lab I 25 Points

143

SELECT … (Fields) AS ..FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

COUNT(*)

Page 144: MySQL Query Lab I 25 Points

144

1] The Number Of Users2] Display The First, Last, and Administrator For All Non-Administrators3] Display The Number Of Non-Administrators Replace The Capture Below!

Page 145: MySQL Query Lab I 25 Points

145

1] Display The Number Of Users That Have An ‘A’ In Their First Name2] Display The Number Of Users That Have An ‘A’ As One Of The First Three Letters In Their First Name 3] Display The Number Of Users That Have An ‘.’ In Their Email Include The Capture Below!

Page 146: MySQL Query Lab I 25 Points

146

SELECT … (Fields) AS ..FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

LENGTH(str)

Page 147: MySQL Query Lab I 25 Points

147

1] Display The Length Of ‘Tom’2] Display The Length Of ‘Dr. Thomas Hicks’; Assign That Value To LEN_NAME Replace The Capture Below!

Page 148: MySQL Query Lab I 25 Points

148

1] Display The Length Of ‘Tom’2] Display The Length Of ‘Dr. Thomas Hicks’ 3] Display The First Name and The Length Of The First Name For All Users Whose ID Is Greater Than Or Equal To 8 Replace The Capture Below!

Page 149: MySQL Query Lab I 25 Points

149

1] Display The Number Of User Whose First Name Is 4 Characters In Length; Assign That Value To No_4_First 2] Display The Number Of User Whose First Name Is 5 Characters In Length; Assign That Value To No_5_First 3] Display The Number Of User Whose Last Name Is 7 Characters In Length; Assign That Value To No_7_Last Include The Capture Below!

Page 150: MySQL Query Lab I 25 Points

150

SELECT … (Fields) AS ..FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

LPAD(str,#,str)RPAD(str,#,str)

Page 151: MySQL Query Lab I 25 Points

151

1] Display All Of The User IDs; Pad Them On The Left With Blanks, .’s, and 0’sWe Often Want To LPAD Numeric

Replace The Capture Below!

Page 152: MySQL Query Lab I 25 Points

152

1] Combine The First And Last Names Of All Users; Pad Them With 10 .’s On The Right

We Often Want To LPAD Strings On The Right With Blanks For Spacing On Reports

Replace The Capture Below!

Page 153: MySQL Query Lab I 25 Points

153

Report GenerationFormatting

Page 154: MySQL Query Lab I 25 Points

154

1] We Often Combine The Concat, Padding, Left, Right, Upper, Lower, etc. To Produce Single-Line Output For Reports. Replace The Capture Below!

Ignore Collateral Output!It Would Not Appear In The Report!

Page 155: MySQL Query Lab I 25 Points

155

SELECT … (Fields) AS ..FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

REVERSE(str)

Page 156: MySQL Query Lab I 25 Points

156

1] Display ‘Tom Hicks’ In Reverse Order2] Display The First Name Of All Of The Users In Reverse Order. Replace The Capture Below!

Page 157: MySQL Query Lab I 25 Points

157

SELECT … (Fields) AS ..FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

REPEAT(str,#)

Page 158: MySQL Query Lab I 25 Points

158

1] Display ‘Tom’ 4 Times2] Display 25 Blanks3] Display 60 *’s Replace The Capture Below!

Page 159: MySQL Query Lab I 25 Points

159

SELECT … (Fields) AS ..FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

REPLACE(str,str,str)

Page 160: MySQL Query Lab I 25 Points

160

1] Display The Replacing Of All ‘W’s in WWW.trinity.edu with ‘w’s2] Display The Replacing Of All ‘W’s in WWW.trinity.edu with ‘*’s 3] Display The Replacing Of All ‘.’s in WWW.trinity.edu with nothing Replace The Capture Below!

Page 161: MySQL Query Lab I 25 Points

161

SELECT … (Fields) AS ..FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

SPACE(#)

Page 162: MySQL Query Lab I 25 Points

162

1] Display 20 ‘ ‘s2] Display The First Name + 5 ‘ ‘s + Last Name of All Users; Assign It To Info. Replace The Capture Below!

Page 163: MySQL Query Lab I 25 Points

163

SELECT … (Fields) AS ..FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

BIN(#), OCT(#), HEX(#)

Page 164: MySQL Query Lab I 25 Points

164

1] Display Binary, Octal, and Hex Values of 15, 65, 255, 512, and 256 Replace The Capture Below!

Page 165: MySQL Query Lab I 25 Points

165

SELECT … (Fields) AS ..FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

MOD(#,#)# % #

Page 166: MySQL Query Lab I 25 Points

166

1] Display 15 Mod 6 Using Both The Mod and % Functions2] Display 1000 Mod 10 Replace The Capture Below!

Page 167: MySQL Query Lab I 25 Points

167

SELECT … (Fields) AS ..FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

ABS(#)

Page 168: MySQL Query Lab I 25 Points

168

1] Display The Absolute Values Of 10, -10, 2.2, and -2.2 Replace The Capture Below!

Page 169: MySQL Query Lab I 25 Points

169

SELECT … (Fields) AS ..FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

PI(), LOG2N(#)

Page 170: MySQL Query Lab I 25 Points

170

1] Display PI2] Display The Area Of A Circle Whose Radius Is 3; Assign It To Area3] Display The Log (Base 2) Of 15 and 1,000,000 Replace The Capture Below!

Page 171: MySQL Query Lab I 25 Points

171

SELECT … (Fields) AS ..FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

SQRT(#)

Page 172: MySQL Query Lab I 25 Points

172

1] Display The Square Root of 2, 4, 9, and 12] Display The Square Root of15,248,792,196 Replace The Capture Below!

Page 173: MySQL Query Lab I 25 Points

173

SELECT … (Fields) AS ..FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

NOW(), DAY(d), MONTH(d)YEAR(d)

Page 174: MySQL Query Lab I 25 Points

174

1] Display The Date Today2) Display The Day Today3) Display The Month Today4] Display The Year Today Replace The Capture Below!

Page 175: MySQL Query Lab I 25 Points

175

SELECT … (Fields) AS ..FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

HOUR(d), MINUTE(d)

SECOND(d)

Page 176: MySQL Query Lab I 25 Points

176

1] Display Now and The Current Hour2) ] Display Now and The Current Minute3) ] Display Now and The Current Second Replace The Capture Below!

Page 177: MySQL Query Lab I 25 Points

177

SELECT … (Fields) AS ..FROM … (Table(s))

WHERE … (Conditions)

ORDER BY …

DAYOFWEEK(d), DAYNAME(d)

MONTHNAME(d), DAYOFYEAR(d)

Page 178: MySQL Query Lab I 25 Points

178

1] Display Day Of Week And Day Name For Christmas of 20102] Display Day Of Week And Day Name For Dec 26th of 20103] Display Day Of Month And Month Name For Christmas of 20104] Display Day Of Year And Day Of Year For Christmas of 2010

Replace The Capture Below!

Page 179: MySQL Query Lab I 25 Points

179

HOW MANY DIGITSOF ACCURACY

CAN BE REPRESNTED

AS BIG INTEGERS?

Page 180: MySQL Query Lab I 25 Points

180

From The Capture Below, We Can See That The Big Integer Calculation Is Accurate To At Least 5 Digits; Continue This Process, Increase It By 1 Until It Is Goes Into Scientific Notation. Screen Capture Your Last Three SELECT Statements. Replace The Capture Below!

Page 181: MySQL Query Lab I 25 Points

181

STATUS

Page 182: MySQL Query Lab I 25 Points

182

SHOW Your Status. Replace The Capture Below!

Page 183: MySQL Query Lab I 25 Points

183

More Questions

Page 184: MySQL Query Lab I 25 Points

184

Questions

_____ {T/F} The Foundations Of SQL Are Generic.

_____ {T/F} Each And Every Implementation Of SQL Have Exactly The Same Function Set.

_____ {T/F} Some Implementations Of SQL Have Added Some Function Enhancements That May Not Be Available On Other SQL Systems.

SQL is an Acronym For _________________________________

Page 185: MySQL Query Lab I 25 Points

185

MySQL Function Listing

Links