,ch03.13605 Page 136 Wednesday, November 29, 2000 4:42
,ch03.13605 Page 138 Wednesday, November 29, 2000 4:42 PM WHERE a.au_id = t1.au_id AND t1.title_id = t2.title_id ORDER BY t2.title — ANSI style query with multiple tables SELECT a.au_lname, a.au_fname, t2.title FROM authors a JOIN titleauthor AS t1 ON a.au_id = t1.au_id JOIN titles AS t2 ON t1.title_id = t2.title_id ORDER BY t2.title Multi-key Join Example: –theta style query with multipart key SELECT s1.store_id, s1.title_id, s2.qty FROM sales s1, sales_projections s2 WHERE s1.store_id = s2.store_id AND s1.title_id = s2.title_id ORDER BY s1.store_id, s2.title_id — ANSI style query with multipart key SELECT s1.store_id, s1.title_id, s2.qty FROM sales s1 JOIN sales_projections s2 ON s1.store_id = s2.store_id AND s1.title_id = s2.title_id ORDER BY s1.store_id, s2.title_id The WHERE clause The WHERE clause is an extremely potent component of the SELECT statement. The WHERE clause provides most of the search conditions that cull unwanted data from the query; the remaining search conditions are satisfied by the HAVING clause (explained later in this section). A poorly written WHERE clause can ruin an otherwise beautiful SELECT statement, so the nuances of the WHERE clause must be mastered thoroughly. This is an example of a typical query and a multipart WHERE clause: SELECT a.au_lname, a.au_fname, t2.title, convert(char,t2.pubdate) FROM authors a JOIN titleauthor t1 ON a.au_id = t1.au_id JOIN titles t2 ON t1.title_id = t2.title_id WHERE (t2.type = ‘business’ OR t2.type = ‘popular_comp’) AND t2.advance > $5500 ORDER BY t2.title 138 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