如何在SQL中进行以下访问?
我有以下查询如何在SQL中进行以下访问?
SELECT dictionaryEncryptedIndex, filelocation FROM `DictionaryTable` WHERE `dictionaryEncryptedWord` LIKE '0x0E6E'";
在C#我遍历从上面的查询和我使用的每个循环迭代以下查询的结果让我的最终结果:
SELECT * FROM `MaskedIndexTable` WHERE `maskedIndexEncryptedIndex`
LIKE '" + dictionaryEncryptedIndexFROMABOVEQUERY + "'
AND `fileLocation` = '" + filelocationFROMABOVEQUERY + "'";
的关系dictionaryEncryptedIndex和maskedIndexEncryptedIndex之间不是一对一的关系。
有谁知道如何在一个可用于Microsoft Access的SQL查询中执行上述操作?
我已经试过许多东西,如:
SELECT * from DictionaryTable, MaskedIndexTable WHERE MaskedIndexTable.maskedIndexEncryptedIndex = DictionaryTable.dictionaryEncryptedIndex
AND MaskedIndexTable.fileLocation =DictionaryTable.fileLocation
AND `dictionaryEncryptedWord` LIKE '0x0E6E'
SELECT dictionaryEncryptedWord, DictionaryTable.filelocation
FROM DictionaryTable
INNER JOIN MaskedIndexTable
ON (MaskedIndexTable.maskedIndexEncryptedIndex =DictionaryTable.dictionaryEncryptedIndex )
WHERE `dictionaryEncryptedWord` LIKE '...'
SELECT distinct *
FROM MaskedIndexTable
INNER JOIN DictionaryTable
ON (MaskedIndexTable.maskedIndexEncryptedIndex = DictionaryTable.dictionaryEncryptedIndex )
WHERE MaskedIndexTable.Id IN
(
SELECT DictionaryTable.Id
FROM DictionaryTable
WHERE `dictionaryEncryptedWord` LIKE '..')
AND `dictionaryEncryptedWord` LIKE '...'
,但他们都不来产生正确的结果(结果我用我的C#代码获得)
回答:
你需要的,如果要改变这种你想在LIKE标准中使用通配符。
首先在Access中创建类似于你叫encryptedWordsQuery
SELECT DictionaryTable.dictionaryEncryptedIndex, DictionaryTable.fileLocation FROM DictionaryTable
WHERE (((DictionaryTable.dictionaryEncryptedWord) Like "0x0E6E"));
其次在Access中创建一个查询,第一个查询,如下所示:
SELECT MaskedIndexTable.maskedIndex, MaskedIndexTable.maskedIndexEncryptedIndex, MaskedIndexTable.fileLocation FROM MaskedIndexTable
WHERE Exists (SELECT *
FROM encryptedWordsQuery
WHERE MaskedIndexTable.maskedIndexEncryptedIndex = encryptedWordsQuery.dictionaryEncryptedIndex
AND MaskedIndexTable.fileLocation = encryptedWordsQuery.FileLocation);
我觉得它更容易,而创建两个单独的查询不仅仅是Access中的一个。
回答:
我认为这应该起作用 - 如果你能够发布样本数据,我们可以让一个SQLFiddle来演示它。
SELECT dt.dictionaryEncryptedIndex, dt.filelocation FROM DictionaryTable dt
INNER JOIN MaskedIndexTable mit
ON mit.fileLocation = dt.fileLocation
AND mit.maskedIndexEncryptedIndex = dt.dictionaryEncryptedIndex
WHERE dt.dictionaryEncryptedWord LIKE '0x0E6E*'
以上是 如何在SQL中进行以下访问? 的全部内容, 来源链接: utcz.com/qa/259042.html