Download presentation
Presentation is loading. Please wait.
Published byEmmeline White Modified over 9 years ago
1
I want to do SQL, I start as if I am doing a regular query.
2
When I get to the user interface, I add the table and then I go to the icon that lets me look at how to view what I did and I select SQL. It brought up SELECT FROM books; I wanted to see all fields, so I put in the * so I am now selecting all fields from the table books.
4
Now I just want to see specific fields. I am going to change the * and list the fields that I want to see. I coded it in a separate word document to get a better size to show the class. I am going to copy and paste over to the Query3 that now contains SELECT * FROM books; Please note the semi-colon at the end of the SQL command.
5
Now I have the SQL in query 3. To execute I click on the icon to display the results.
6
If I put a field that does not exist in the field list, I get this response. There is no field called yr on the table.
7
I corrected and put the accurate field name of yearPub.
9
This is WRONG. The order of the clauses is important. The FROM clause should be on the second line and the WHERE clause on the third line.
10
It is now corrected. Please note again that there is a semi-colon only after all of the clauses. Also remember, this is just a copy in notepad so the class can see the code better. This is Query3 that I will run.
11
I showed the result and I showed the separate copy in notepad since I cannot show the query code and the result at the same time. Again, this is just a copy in notepad.
12
It is important when I compare fields to have the fields of the same type. I put the ABC in quotes because it is a text/string field and therefore must be enclosed in quotes. If I did not use quotes, it would assume ABC was the name of a field. Numerics are not put in quotes if they are being compared to a numeric field.
13
I amde some changes in the structure and made edition a numeric field, I believe it was text.
14
Now I am checking two things in an AND relationship. The second thing is comparing edition (which I made numeric) to 2. A numeric to numeric test.
15
Text fields are pushed against the left wall and numeric fields are pushed against the right wall.
16
This shows the SQL and the user interface. Please note that sometimes when you bring up the user interface it changes the code in the SQL by putting in a lot of parenthesis etc that are not needed.
19
This shows the SQL generated by Access. This is not the way I want you to write it. Note that books.ISBN means the ISBN field on the books table, but since I am only using one table, these are not necessary. Also note the parenthesis, none of which are needed in this example.
21
I changed the AND to an OR so I get records that either have ABC or have edition 2.
22
This is an OR relationship.
23
Now I want to do this problem - see the next few pages.
24
This is not what I wanted. It reads publisher ABC and edition 2 OR just yearPub > 2003.
25
When I put in the parenthesis it resolves correctly. This reads publisher ABC AND either edition 2 OR yearPub > 2003.
30
This is how the SQL shows up on the quey user interface. Note that ABC is repeated because it has to be true.
31
This is the way that it is generated by Access.
32
This does not have the parenthesis so it will not solve my problem - it will resolve incorrectly.
34
This shows the fact that I get the wrong output - one of the records has CDE. Note that I went back and changed the data for better results. See list of data on a previous slide.
35
This shows the wrong code in the user interface.
36
When I want to copy a database, I go into windows explorer and drag it to another drive. This mdb is also what I would attach to an email.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.