使用右外连接将访问查询转换为sqlite查询

时间:2012-08-29 18:39:03

标签: sqlite ms-access outer-join

SELECT t13_Literature_Material_Codes.Databank, t13_Literature_Material_Codes.BASE_NUMB, t13_Literature_Material_Codes.BASE_SYMB, t13_Literature_Material_Codes.BASE_CHAR, t13_Literature_Material_Codes.BASE_MOLW, CorrosionRatesInfo.RatesValidFlag FROM CorrosionRatesInfo RIGHT JOIN t13_Literature_Material_Codes ON CorrosionRatesInfo.BASE_NUMB=t13_Literature_Material_Codes.BASE_NUMB;

如何在sqlite中执行此查询?我看到人们使用左外连接。请提供使用类似结构的解决方案,然后我的c ++程序可以通过简单的解析器过程修改查询字符串。

2 个答案:

答案 0 :(得分:0)

在Sqlite中执行此查询:

SELECT t13_Literature_Material_Codes.Databank, t13_Literature_Material_Codes.BASE_NUMB, 
t13_Literature_Material_Codes.BASE_SYMB, t13_Literature_Material_Codes.BASE_CHAR, 
t13_Literature_Material_Codes.BASE_MOLW, CorrosionRatesInfo.RatesValidFlag FROM 
CorrosionRatesInfo RIGHT OUTER JOIN t13_Literature_Material_Codes ON  
CorrosionRatesInfo.BASE_NUMB=t13_Literature_Material_Codes.BASE_NUMB;

只需要添加“RIGHT OUTER JOIN”。

答案 1 :(得分:0)

用户UNION解决此问题

例如

SELECT employee.*, department.*
FROM   employee 
       LEFT JOIN department 
          ON employee.DepartmentID = department.DepartmentID
UNION ALL
SELECT employee.*, department.*
FROM   department
       LEFT JOIN employee
          ON employee.DepartmentID = department.DepartmentID
WHERE  employee.DepartmentID IS NULL

是的,see the example on Wikipedia.