SQL statement example

xiaoxiao2021-03-06  56

SQL: SELECT * INTO B from a where 1 <> 1

Description: Copy Table (copy data, source name: a target table name: b)

SQL: INSERT INTO B (A, B, C) SELECT D, E, F from B;

Description: Display article, author and last reply time

SQL: SELECT A.TITLE, A.USERNAME, B.Adddate from Table A, (Select Max (AddDDate) Addddate from Table Where Table.title = a.title) B

Description: Outer connection query (table name 1: a table name 2: b)

SQL: SELECT A.A, A.B, A.C, B.C, B.D, B.F from a left out join b on a.a = b.c

Description: Reminder in advance in advance

SQL: SELECT * FROM schedule Arranging WHERE DATEDIFF ('minute', f Start time, getdate ())> 5

Description: Two related tables, delete information that is already in the secondary table in the primary table

SQL:

Delete from info where not exists (Select * from infobz where info.infid = infobz.infid)

Description:

SQL:

SELECT A.NUM, A.NAME, B.UPD_DATE, B.PREV_UPD_DATE FROM TABLE1, (SELECT X.NUM, X.UPD_DATE, Y.UPD_DATE PREV_UPD_DATE FROM (SELECT NUM, UPD_DATE, INBOUND_QTY, STOCK_ONHAND FROM TABLE2 WHERE TO_CHAR (UPD_DATE, 'YYYY / mm') = to_char (sysdate, 'yyyyy / mm')) X, (Select Num, Upd_date, stock_onhand from table2 where to_char (upd_date, 'yyyy / mm') = to_char (to_date (to_char (sysdate, ' YYYY / MM ') ||' / 01 ',' YYYY / MM / DD ') - 1,' YYYY / mm ')) y, where x.num = y.NUM ( ) and x.inbound_q nVL ( Y.stock_onhand, 0) <> x.stock_onhand) b where a.num = B.NUM

Description:

SQL:

select * from studentinfo where not exists (select * from student where studentinfo.id = student.id) and department name = ' "& strdepartmentname &"' and professional name = ' "& strprofessionname &"' order by gender, students, the college entrance examination total score

转载请注明原文地址:https://www.9cbs.com/read-117989.html

New Post(0)