1. 連接列値問題 複数列作為単一列ソリューション DB2、Oracle、PostgreSQL SELECT ename || ' WORKS AS A ' || JOB AS msg FROM emp WHERE deptno=10 SQL Server SELECT ename + ' WORKS AS A ' + JOB AS msg FROM emp WHERE deptno=10
2. 戻るロー数制限問題 前nローを戻るソリューション DB2 SELECT * FROM emp fetch first 5 rows only MySQL&PostgreSQL SELECT * FROM emp limit 5 Oracle SELECT * FROM emp WHERE rownum <= 5 SQL Server SELECT TOP 5 * FROM emp
3. 随机返回n条记录問題 随机返回n条记录ソリューション DB2 SELECT * FROM emp ORDER BY rand() FETCH FIRST 5 ROWS ONLY MySQL SELECT * FROM emp ORDER BY rand() LIMIT 5 PostgreSQL SELECT * FROM emp ORDER BY random() LIMIT 5 Oracle SELECT * FROM (SELECT ename, job FROM emp ORDER BY dbms_random.value() ) WHERE rownum <= 5 SQL Server SELECT TOP 5 * FROM emp ORDER BY newid() 〉〉〉〉〉〉つつき
4. 查找空值問題 查找空值ソリューション DB2 ,MySQL,PostgreSQL,Oracle,SQL Server SELECT * FROM emp WHERE COMM IS NULL
5. 将空值转换成实际值問題 查找空值ソリューション DB2 ,MySQL,PostgreSQL,Oracle,SQL Server SELECT coalesce(comm,0) FROM emp --coalesce函数返回参数列表中,第一个不是null的量
6. 模糊查询問題 按模式查询ソリューション DB2 ,MySQL,PostgreSQL,Oracle,SQL Server SELECT * FROM emp WHERE (ename like '%I%' or job like '%ER')