aspose file tools*
The moose likes JDBC and the fly likes MySQL question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "MySQL question" Watch "MySQL question" New topic
Author

MySQL question

Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 598

Is it correct to have an OR in the WHERE clause of a JOIN??


===>SCJP 1.5(72%)<===
==>SCWCD1.5(76%)<===
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39755
    
  28
Don't know. It sounds like the sort of thing which should be possible: try it. Beware of multiple joins however.
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3716
    
    5

No it's terrible.

Lol. Actually it's fine to have but keep in mind database query optimizes tend to choke on disjunctive (= OR) query paths. In other words, the more OR's you have, the great the possibility its going to run poorly. There are often ways you can eliminate OR using boolean logic, so try to find one. Otherwise, if your query is especially large and uses OR, you might want to break it into multiple queries. This is a good example of syntax being perfectly fine, but in practice having issues.


My Blog: Down Home Country Coding with Scott Selikoff
Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 598

Yes,it didnt give a syntax error but the performance was so bad that I thought it might not be a good practise....will try to use boolean logic.

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MySQL question