PHP MySql Web Hosting

PHP and MySQL Web Development

,ch03.13605 Page 133 Wednesday, November 29, 2000 4:42

Filed under: SQL in a Nutshell — webmaster @ 10:38 am

,ch03.13605 Page 134 Wednesday, November 29, 2000 4:42 PM — the schema, table, and then column name must be listed! FROM employee, salesadmin.sales_summary WHERE employee.emp_id = salesadmin.sales_summary.emp_id ORDER BY employee.emp_id; Literal expressions may be used as a select list item. Mathematics calculations can be entered as a select list item. In Microsoft SQL Server, no FROM statement is needed. In Oracle, the calculation should be executed against the system table called DUAL. The table allows the SELECT command to retrieve values where no table exists. For example: –QUERY (Microsoft) SELECT 2 + 2 –QUERY (Oracle) SELECT 2 + 2 FROM dual –RESULTS 4 The FROM clause The FROM clause generally serves two purposes: to list the tables and views where a query retrieved its data (with a comma between each tablename); and to assign an alias for long table names, making coding lengthy queries a lot easier. An alias can be assigned in the FROM clause by two means: by typing the table- name, a space, and the alias; or by typing the tablename, AS, and the alias. The example below illustrates each of these techniques. An example of a query that extracts data from multiple tables might have a FROM and WHERE clause that is coded in the following manner: SELECT e.emp_id, e.fname, e.lname, j.job_desc FROM employee e, jobs j WHERE e.job_id = j.job_id ORDER BY e.fname, e.lname Once an alias has been assigned in a query, be sure to use it exclusively for table references within that query. Do not mix references to the full table name and the alias in a query. This query retrieves the emp_id (first and last name of each employee stored in the employee table) and joins the job_id of the employee, which is a code number, with the full job description found in the JOBS table. 134 Chapter 3 SQL Statements Command Reference

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

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Sorry, the comment form is closed at this time.

Powered by PHP MySQL Web Hosting