Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can anyone tell correct my followin

Status
Not open for further replies.

rmutyapu

IS-IT--Management
Nov 2, 2001
24
US
Can anyone tell correct my following query.

Delete from SW_S_TEMP_GUIDS
where uid in (Select a.uId
From SW_S_USER_TABLE a, SW_S_USER_SERVER_MAP b
Where b.o = ?
And b.ou = ?
And b.userId = ?
And b.mailId = a.userId
And b.protocol =?)

I am deleteing rows from table A basing on the subquery.

If my sub query returns nothing, then how can I display the messege and want to come out of the process.

I am using the above sql with Java.

Your help is highly appreciable.

RM
 
Is it true that you're MySQL as your database of choice? If so, MySQL doesn't support subQueries (at least not yet)

You could run your subquery portion first.
Get the string(s) from your result set and place them in a Vector.
Next execute your outer query by building a comma separated list of values (from your Vector) for your "in" clause.

This way, if the subquery portion returns nothing, don't execute the outer query.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top