SQL搜索 - 第二部分

时间:2013-10-08 19:07:56

标签: sqlite

我正在尝试搜索sqlite文件中的所有字段(列),但我一直没有得到有效的结果。这是代码。我应该尝试不同的东西吗?

Select * From session
join sessiontype using(SESSIONTYPEID)
join camera on SESSION.[CameraID] = camera.CameraID
join chemicals on session.[DeveloperID] = chemicals.[ChemicalsID] 
               or session.[FixerID] = chemicals.[ChemicalsID]
join shop on session.[DEVELOPEDBYID] = shop.[ShopID]
join film on session.[FilmID] = film.[FilmID]
join vendor on film.[VendorID] = vendor.[VendorID]
where session.[Identifier] like('%agfa%') 
or session.[Notes] like('%agfa%')
or sessiontype.[SessionTypeName] like('%agfa%')
or camera.[CameraName] like('%agfa%')
or chemicals.[ChemicalsName] like('%agfa%')
or session.[DeveloperTemp] like('%agfa%')
or session.[DeveloperTime] like('%agfa%')
or session.[FixerTemp] like('%agfa%')
or session.[FixerTime] like('%agfa%')
or shop.[ShopName] like('%agfa%')
or session.[StopBathTemp] like('%agfa%')
or session.[StopBathTime] like('%agfa%')
or vendor.[VendorName] like('%agfa%')
order by session.[Identifier], sessiontype.[SessionTypeName], session.[Date]

我只有一个包含'agfa'的条目。 以下行两次返回1个条目:     加入化学品会议。[DeveloperID] =化学品。[ChemicalsID]                或会话。[FixerID] =化学品。[ChemicalsID]

以下条目不返回任何结果:     加入化学品会议。[DeveloperID] =化学品。[ChemicalsID]                AND session。[FixerID] = chemicals。[ChemicalsID]

删除该行会返回正确的1个条目。

1 个答案:

答案 0 :(得分:0)

  1. 也许你想/需要一些外连接?
  2. 您在使用Oracle吗?一旦我在JOIN中遇到一个奇怪的OR子句问题 - 它工作不正确 - abybody知道为什么......通过将JOIN(我更喜欢)转换为WHERE子句来实现实验
  3. 注意:OR和LIKE是非常昂贵的操作