Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

mySQL Inner join

 
Jeppe Sommer
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am having a problem with a SQL query and inner join.

My problem is that I only want rows to be returned IF invoicelog.statusCode != 'OK' is true. The "statusCode = OK" may NOT exist in the rows being returned.

The query below returns one row with invoiceID = 2663, even that statusCode = OK does exists in one of the two rows being returned from invoicelog.


Running the query:

it returns two rows:


So how do I ensure that I donĀ“t get any rows returned if "StatusCode = OK" exists in one of the rows from table invoicelog .
 
Jan Cumps
Bartender
Posts: 2588
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use 'not 'exists': http://dev.mysql.com/doc/refman/5.0/en/exists-and-not-exists-subqueries.html
or 'not in': http://dev.mysql.com/doc/refman/5.0/en/any-in-some-subqueries.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic