I am starting SQL and I am working on a PHP + MySql application. The database used by the application has many tables, such as swverforftver:
SWVerID FileTypeVerID
1111 897897
1111 32352342
2222 897897
2222 32352342
2222 222222222
3333 222222222
and filetypeversion table:
FileTypeVerID PubID FileTypeID IsRelatedTo IsPreviousVersionOf
897897 789789798 6575 dw qweq
32352342 68767 231232 dasdasda asdasda
222222222 333333 231231 asd wdadw
and softwareversion table:
SWVerID SWID Name
1111 1234 Adobe Reader
2222 5678 Word
3333 4444 ExcelVersion
I am using the SQL command to retrieve the SWVerID values from the softwareversion table associated with the FileTypeVerID value 897897 and which is NOT associated with the value 222222222 from the swverforftver table.
The command I use is the following:
SELECT distinct softwareversion.SWVerID
FROM softwareversion,
filetypeversion,
swverforftver AS stv JOIN
swverforftver AS stv2 ON stv2.SWVerID = stv.SWVerID
WHERE stv2.FileTypeVerID=filetypeversion.FileTypeVerID
AND stv.SWVerID=softwareversion.SWVerID
AND (stv2.FileTypeVerID = 897897)
AND NOT (stv.FileTypeVerID = 222222222)
Instead of returning to me only the value 1111, which is the only value associated with 897897 and not 222222222, it returns me tables with two values:
SWVerID
1111
2222
Does anyone know something about this issue? Also, the SQL command should not change in structure from the current one (it should have JOIN and AS basically) ...
Anto