Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4623882
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:03:05+00:00 2026-05-22T03:03:05+00:00

I am SQL novice and I am working on a PHP+MySql application. The database

  • 0

I am SQL novice and I am working on a PHP+MySql application. The database the application is using has many tables, such as swverforftver:

SWVerID  FileTypeVerID
1111     897897
1111     32352342
2222     897897
2222     32352342
2222     222222222
3333     222222222

and the table filetypeversion:

FileTypeVerID      PubID       FileTypeID      IsRelatedTo    IsPreviousVersionOf
897897             789789798   6575            dw             qweq
32352342           68767       231232          dasdasda       asdasda
222222222          333333      231231          asd            wdadw

and the table softwareversion:

SWVerID  SWID    Name
1111     1234    Adobe Reader
2222     5678    Word
3333     4444    ExcelVersion

I am using an SQL command to retrieve the SWVerID values from the softwareversion table associated with the FileTypeVerID 897897 value AND WHICH ARE NOT associated with the 222222222 value from the swverforftver table.

The command I am using 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 me only the 1111 value, being the only value associated with 897897 and not with 222222222, it returns me a tables with two values:

SWVerID
1111
2222

Does anyone know something about this issue? Also the SQL command should not be modified in structure from the current one (it should have the JOIN and AS basically)…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T03:03:06+00:00Added an answer on May 22, 2026 at 3:03 am

    You get the second row in your result set because there exist 3 rows for SWVerID = 2222, so the condition is evaluated to true for this. Use a NOT IN instead:

    SELECT  distinct softwareversion.SWVerID 
    FROM    softwareversion,
            filetypeversion,
            swverforftver AS stv 
    WHERE   stv2.FileTypeVerID=filetypeversion.FileTypeVerID 
    AND     stv.SWVerID=softwareversion.SWVerID 
    AND     (stv2.FileTypeVerID = 897897) 
    AND NOT EXISTS (select null from swverforftver AS stv2 WHERE stv2.SWVerID = stv.SWVerID AND 
    stv2.FileTypeVerID = 222222222)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

SQL Server 2005/2008 Express edition has the limitation of 4 GB per database. As
I'm more of a MS-SQL / PostgreSQL guy, but I'm working on a MySQL
I'm working on a football site which, along with many features, lists result tables.
I am working with ColdFusion 9 on a Windows Server, using MS SQL Server
When restoring a SQL Server Database, I notice that there are 3 different Recovery
SQL Experts, Is there an efficient way to group runs of data together using
SQL is not my forte, but I'm working on it - thank you for
I'm working on a stored proc that executes some dynamic sql. Here's the example
I'm currently working on an ASP.NET MVC project using NHibernate and I need to
Please I am very new to PDO, rather a novice at PHP as well.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.