Simple query
Select column
Query all records Select * from scott.emp Query Some fields of all records Select Empno, Ename, Job from Scott.emp Query Some fields Different records Select Distinct job scott.emp The "Distinct" reserved word refers to the display When the same record is removed, the corresponding "all" will retain the same record, and the default is "all". Choice
Single condition filter Select Empno, ename, Job from scott.emp where job = 'manager'Select Empno, Ename, Sal from Scott.emp Where Sal <= 2500 Single Condition Query Used Comparison Operators = (equal)! = Equal to) ^ = (not equal) <> (not equal) <(less)> (greater than)> = (greater than or equal) IN (List) Not in (not listed) BetWeen NOT BETWEEN (not between block) (LIKE and NOT LIKE) Query for the character field,% represents the string of any length, _ Underline represents an arbitrary character.) Not likech IS NULL (Whether to empty) Is Not NULL (Whether to empty) combination condition filter Select Empno, ename, job from scott.emp where job> = 'Clerk' and Sal <= 2000Select Empno, ENAME, JOB FROTT.EMP WHERE NOT JOB = 'Clerk' Logic Comparison Man and (with) OR (or) NOT Samples Select Empno, Ename, Job from Scott.emp Where Job <= 'Clerk' Order by Job ASC, SAL Descast Representative Ascending Arrange, DESC represents descending order, and multiple sort fields are divided by commas. Grouping Result Group query refers to grouping query results in a field group. The following is listed in the message in the message in the message, and the number is decremented by the number of messages. select guestbook.posterid, classmates.name, count (guestbook.postid) from guestbook inner join classmates on guestbook.posterid = classmates.idgroup by classmates.name, guestbook.posterid having count (guestbook.postid)> 10 order by count (guestbook .postid) The non-polymeric field in the DESC output field must appear in the group BY clause. Output: 7 Taotao 3821 Zhu Yu 3524 Thank you can 231 Jianwen 21103 阚 伟 2011 1 193 Ren Long 11where Check if each record is eligible, Having is to check whether the groups after the group meets the conditions.
Join query
The unconditional connection unconditional connection query is combined with the records of each table in the "Descartes". For example, there are 4 records in the Scott.Dept Table, and there are 14 records of Scott.emp table, and its "Cartes" will have 4 * 14 = 56 records. Select Emp.empno, Emp.ename, Emp.deptno, Dept.dname, Dept.loc from Scott.emp, Scott.DEPT Conditions
WHERE clause (the result of the following is the same as the inline result) - join in where clause.use pubsselect t.title_id, t.title, s.qtyfrom titles as t, sales as swhere t.title_id * = s. Title_id from the subsection (JoIn join) Inner Jion SELECT T.TITLE_ID, T.TITLE, S.Qty from Titles As T.Title_ID * = S.TITLE_ID Outer Contact (Outer Join) SELECT A.AU_FNAME, A.AU_LNAME, P.PUB_NAMEFROM AUTHORS A LEFT OUB_NAMEFROM AUTHORS A LEFT OUTER JOIN PUBLISHERS P on A.city = P.CITYORDER BY P.PUB_NAME ASC, A.AU_LNAME ASC, A.AU_FNAME ASC Note: In the internal connection The status of the table involved in the connection is equal. In an external connection, the table involved in the connection has a master-slave, with each row of data from the primary table, the data columns from the table, and the data that meets the connection conditions will be directly returned to the result set, and the columns that do not meet the connection conditions After the NULL value will be filled back to the result set. Cross Join has a variety of joint forms, but they can be interchanged, do not say this.
To Be Continue ........