Another look at the ER diagram in Figure

Another look at the ER diagram in Figure 2-1 shows you that a salesperson is related to a customer which is another way of saying that a salesperson has responsibility for a customer. You ll also find tables (SalesOrderHeader and SalesOrderDetail, for example) that contain attributes that relate to money transactions between customers and the company. Building a SQL Query Having all your stuff nicely stored in a database (relational or otherwise) is a nice start, but if you can t access your information quickly and efficiently, you ll find yourself up a certain creek rather quickly without a certain paddle. This is where querying a database comes in. As you might expect with anything involving computers, a specific language is needed to enable us humans to communicate with that laptop or desktop machine and actually do something with the information stored in that database on the hard drive. This language is Structured Query Language (SQL). SQL was specifically designed to work with databases and can be used to access data (to be displayed in a report), update data within a table, or insert new values into the table. For the purposes of working with Reporting Services, you need to focus only on using SQL to display information. Being SELECTive You build SQL statements or queries by stringing together terms including one or more keywords that look pretty much like plain old English. The SELECT keyword, for example, indicates that you want to retrieve information from one or more tables in the database to which you are connected. When you use the SELECT statement, you also have to indicate what you want to select as well as from which table in the database. The keyword FROM is used to precede the names of the tables in which the selected columns are located. For example, the following syntax retrieves the customer ID, order date, and subtotal from the SalesOrderHeader table: SELECT customerID, OrderDate, SubTotal FROM SalesOrderHeader Refer to your handy entity-relationship (ER) diagram (see Figure 2-1) for the column names and then use those names as the columns to select in the SQL statement. If you do not correctly spell what you want to select, or you don t use the proper syntax, you ll receive an error. The error message can look like Incorrect syntax near . . . or Invalid object name. . . . Chapter 2: Retrieving Data from a Database 33

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost JSP Web Hosting services

Bookmark the permalink.

Comments are closed.