This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes mySQL Inner join Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "mySQL Inner join" Watch "mySQL Inner join" New topic
Author

mySQL Inner join

Jeppe Sommer
Ranch Hand

Joined: Jan 07, 2004
Posts: 270
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

Joined: Dec 20, 2006
Posts: 2491
    
    8

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

OCUP UML fundamental and ITIL foundation
youtube channel
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: mySQL Inner join
 
Similar Threads
SQL subquery performs too slowly
Stumped on a SQL Statement
Difference between inner and outer joins
Order in bind variable for PreparedStatement in Java
Another Enthuware question doubt regarding JPQL