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 Seeking help on a complex SQL I reckon, wish get a simple one from answer 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 "Seeking help on a complex SQL I reckon, wish get a simple one from answer" Watch "Seeking help on a complex SQL I reckon, wish get a simple one from answer" New topic
Author

Seeking help on a complex SQL I reckon, wish get a simple one from answer

Steven Jiang
Greenhorn

Joined: Mar 01, 2008
Posts: 22
Hi All

Another sql to ask here. we have a table
File(name ,date, file_size).
anyone has simple query to list name of file where the related size is not 0

let me give some sample data.
name date size
a 1/1/2001 0
a 2/1/2002 2
a 3/3/2003 0
b 1/1/2000 3
b 2/2/2001 4

If I run the query, it should list "b" only as "a" has two related size = 0.

Thanks in advance.

I know a complex query already, just want a simple one.
my query is


I gotta keep learning...
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


select distinct(name) from File where size!=0

more faster
select distinct(name) from File where size > 0
Steven Jiang
Greenhorn

Joined: Mar 01, 2008
Posts: 22
Balu Sadhasivam wrote:
select distinct(name) from File where size!=0

more faster
select distinct(name) from File where size > 0


thanks for that, but your answer is not right, if you run it against the table I created, you will get "a", "b", but "a" is related two records with '0' in size field.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

I can't help you much, but I modified your original query little bit.


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874

Steven Jiang wrote:[you will get "a", "b", but "a" is related two records with '0' in size field.


oh yeah.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Seeking help on a complex SQL I reckon, wish get a simple one from answer
 
Similar Threads
JPA native Query - Select... where... IN, How to set list of values to setParameter()?
how to dynamically set values in check box
how to dynamically set values in check box
any good hql query for this scenario?
inconvertible types found : int required: java.lang.Short