Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MySQL question

 
Duran Harris
Ranch Hand
Posts: 608
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it correct to have an OR in the WHERE clause of a JOIN??
 
Campbell Ritchie
Sheriff
Posts: 48910
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4014
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Duran Harris
Ranch Hand
Posts: 608
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic