Ah wow, thank you! I believe that has got it.
************* Start My current SQL query *************
SELECT DISTINCT Pictures.PicFilename, Pictures.PicId, Pictures.PicDate
...truncated statement
FROM (Pictures
LEFT JOIN Attributes ON Pictures.PicId=Attributes.PicId)
LEFT JOIN KeyWords...
I thought examples of what I meant by the JOIN comparison may help...
Two examples of a valid record that exist in just one table:
1) A call for a KeyWords.Keyword but "Any" Attributes.Data
2) The reverse, a call for a Attributes.Data but "Any" KeyWords.Keyword
One example of a valid record...
Using my last posted SQL query statistically helps because there are far more records, about a 10:1 ratio, that fall under the case of having a, KeyWords.Keyword and no Attributes.Data, than there are records that have a, Attributes.Data and no KeyWords.Keyword.
However, as expected the test...
My problem is definately the JOIN unfortunately I don't know how to fix it. On a hunch I inverted your statement from:
FROM Pictures LEFT JOIN ( Attributes LEFT JOIN KeyWords ON Attributes.PicId=KeyWords.PicId ) ON Pictures.PicId=Attributes.PicId
to:
FROM Pictures LEFT JOIN ( KeyWords LEFT...
Looking over the results with the simplified SQL statement the pictures omitted are exactly the records that lack a Attributes.Data field.
Doesn't this mean the JOIN is somehow responsible? The JOIN in on the PicId.
The PicId for the omitted records would only exist in the Pictures table...
Maybe I am having a Null/field comparison issue here. Running this below also failed to give a complete listing of records.
*****************************
SELECT DISTINCT Pictures.PicFilename, Pictures.PicId, Pictures.PicDate
...truncated statement
FROM Pictures LEFT JOIN ( Attributes LEFT...
This is just running using a DSN on a Windows 2000 server. SQL server, etc. is not installed. The "Is Null" statements should work but the result is still the same as my original SQL statement.
The LEFT JOIN simply adds entries from the Attributes or KeyWords table that match the given...
Thank you again, your swift replies are much appreciated!
This produced an unexpected result though. The resulting table contains a lot of mismatched records.
************* Start My current SQL query *************
SELECT DISTINCT Pictures.PicFilename, Pictures.PicId, Pictures.PicDate...
Well, I just realized the test case I was using to test the modified SQL statement wasn't quite right. It turns out the before and after SQL statements are actually producing the same results afterall. All of the same records are still being omitted.
I believe I've read somewhere that using...
Thank you for your help.
When using JOIN in this way is it still necessary to have:
Attributes.PicId = Pictures.PicId
Attributes.PicId = KeyWords.PicId
in the WHERE clause? The results using the LEFT JOIN as you specified below has already helped by including records that were being left...
Hello, I'm trying to find a solution to a simple search engine's SQL query problem. At the moment my query has a flaw that makes it leave out valid records if the user selects "Any" from a dynamic option (drop down list) menu instead of actually selecting an individual statement. I assigned...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.