Download presentation
Presentation is loading. Please wait.
1
I am now going to do queries in SQL
I am now going to do queries in SQL. I select queries and go into design view.
2
When I went into design view, I added the table and then I went to the icon and selected SQL which brought up the notepad for writing SQL. Note that the SELECT is here to allow me to pick fields and the FROM is there to allow me to specify a table. Since I did an ADD of booktable, it knows I want to use that table and so the FROM reads FROM booktable. Note the semi-colon at the end of the SQL statement. Click on the icon and select SQL to get the notepad for writing SQL.
3
If I do not ADD a table, then it assumes I want to use SQL.
4
SELECT then comes up alone and I need to add the
SELECT then comes up alone and I need to add the * to select all fields and the FROM booktable to select the table.
5
This will select all fields from all records in the booktable table.
6
Instead of using *, I can specify the fields I want to see.
7
Note that if I made a mistake and put an embedded blank in the name of the table, I need to surround it in square brackets to indicate it is really just one name.
8
I complete this if on the next slide.
Note that I must use the quotes in SQL, there is no automatic fix.
11
Therefore I have a data type mismatch.
13
In the user interface these would both be on the criteria line.
15
Shows table. Shows results of query.
16
In the user interface, this would mean one criteria on the criteria line and one on the or line.
17
Show original table. Shows results of query.
19
Now I want to have the criteria above - first I showed it in the user interface.
21
A change in criteria.
24
Now I am doing it in SQL. The rule is that things are resolved from left to right and ANDs are resolved before ORs. The resolution can be changed with parenthesis. In this example, I want publisher to be Course and then I want either of the other two criteria so they must be grouped in parenthesis.
27
Now I removed the parenthesis
Now I removed the parenthesis. The things around the AND are resolve first which means grouped and the OR criteria stands alone.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.