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 wrong query? 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 "wrong query?" Watch "wrong query?" New topic
Author

wrong query?

Elahe Shafie
Ranch Hand

Joined: Dec 12, 2001
Posts: 291
Hi friends,
I try to get the list of bugs where status IS NOT resoved here is my quesry but it doesn't give me the right answer could you please tell me what part I am wrong?
Many thanks,
Elahe


Thanks,
Elahe
Bonnie Beach-Morin
Greenhorn

Joined: Jun 13, 2002
Posts: 13
Your problem probably lies in the 's.text NOT IN ('resolved')' portion of your statement.
The IN keyword usually expects a list of things or a return from another statement.
Try using "s.text != 'resolved" instead.


SJCP2
Elahe Shafie
Ranch Hand

Joined: Dec 12, 2001
Posts: 291
Bonnie I tried your suggestion but still the answer is not correct
any advice....
Elahe
select s.text,b.bugNumber,b.bdesc,b.submittedDate,b.fixedDate,b.userID,b.contact,u.name from bug b, user u, statusDesc s where b.ID=s.ID and b.userId=u.userId and s.text != 'open' and u.name= 'JDR'
Elahe Shafie
Ranch Hand

Joined: Dec 12, 2001
Posts: 291
select s.text,b.bugNumber,b.bdesc,b.submittedDate,b.fixedDate,b.userID,b.contact,u.name from bug b, user u, statusDesc s where b.ID=s.ID and b.userId=u.userId and s.text != 'resolved' and u.name= 'JDR'
Elahe Shafie
Ranch Hand

Joined: Dec 12, 2001
Posts: 291
As I fond out on simple query this part:
s.text != 'resolved'
is correct but there is some thing wrong in my whole query that gives me rong resuld!!!
I want my query gives me the list of bug(date, desc,...) that assigned to the persom that name= Jim and status is not resolved.
What did I do wrong?
Thanks,
Elahe
Elahe Shafie
Ranch Hand

Joined: Dec 12, 2001
Posts: 291
sorry name='JDR'
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

Elahe, does your query return too many results, not enough, we need more info on what is going wrong to help you. Also, table structures are important when creating a join. Make sure you join on all primary/foreign key pairs. Beware of the cartesian product!
Jamie
Elahe Shafie
Ranch Hand

Joined: Dec 12, 2001
Posts: 291
Jammie and Bonnie,
It works and now I am getting right result.
Thank you sooooo much for your support like always,
Elahe
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: wrong query?
 
Similar Threads
I try to get whole row from database but...
What is wrong with my Quesry?!!!
I don't know how to call my object?!!!!
I have a question....
javax.servlet. ServletException error