This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Checking existence query? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Checking existence query?" Watch "Checking existence query?" New topic

Checking existence query?

Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

All I want to know is if Name is not null. I have a unique constraint on my name so I need to ensure none exists which is the same as the one I plan to use.

I am using

and to tell me if such a name exists or not. Is there a better query for this since I am not even looking at the returned name, only if it exists or not.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32819

This version is slightly more efficient because the database doesn't have to return as much data.

Did you want a unique name in general or per component id? The unique index would do it for name only.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Checking existence query?
jQuery in Action, 3rd edition