|
||||
|
MySQL Queries
If you would like to receive weekly emails with articles like this one, email Nora
You will be putting information about classes your organization has on your web site. It will be a lot easier for your students and prospective students to be able to get basic class information from your web site, instead of having to call you. You have decided that you want the following information on your web site:
After designing and building the database, you will have to enter information about your instructors and your classes into the database. Then, you will be able to make the web pages that pull information from your database. All of these functions require the use of "database queries." Database queries are build with a "query language." SQL is the query language you will use. This language is commonly used with MySQL databases on web sites. There are some basic functions in SQL: insert, update, and select. All these queries have a very specific syntax - or grammar. For each query, you have key words that belong to SQL and words that you need to know from your own database. SQL has much more functionality that what is covered here, but the following are some basics.
INSERT Here is some basic information about a Course.
In our scenario, the connection to the Instructor, the Date, and the time are in the CourseSchedule. So, for this Course, we will enter the following values into a record in the database: '', 'Introduction to Textile Designs Around the World', 'This course will feature specific traditional textile fibers and designs from 10 geographic areas of the world. The last class will be a hands on project with Japanese Shibori tie dyeing techniques.', 24, 'none', '$100.00'. '$5.00', 10, 16, 'Beginner' . Notice the '' at the beginning of the list. That means that we aren't sending a value for the CourseID. (see the Link in the first paragraph for why.) If any of the values in the list is a different data type than what we build in the database, the INSERT will fail. The complete query statement for this INSERT is: In this case, there is something for each field; so, we don't have to include a field list. However, if we were only entering information for a few of the fields, we would have to say which fields the information goes in. Your INSERT will fail if your data types don't match the actual database.
|
||||
|
© 2009, Nora McDougall |
||||