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 sql query issue 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 "sql query issue" Watch "sql query issue" New topic
Author

sql query issue

swapnil kataria
Ranch Hand

Joined: Feb 26, 2011
Posts: 64
SELECT LOG_ID FROM LOG_TABLE
WHERE LOG_ID = 261 ORDER BY MODIFIED_DATE

-- a LOG_ID can have multiple record with different MODIFIED_DATE
suppose it will give follwing result

log_id
---------------
261
262
267
323
261

in this 261 is coming twice, but i want it only single time,
if i apply DISTINCT then i have to write like this

SELECT LOG_ID, MODIFIED_DATE FROM LOG_TABLE
WHERE LOG_ID = 261 ORDER BY MODIFIED_DATE

but it will also show duplicate records,
i can understand distinct will not work bcz 261 has two different record with different dates,
but don't want to pick same record second time, means only one record should come in result, but order should be maintained

please help
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5



luck, db
There are no new questions, but there may be new answers.
swapnil kataria
Ranch Hand

Joined: Feb 26, 2011
Posts: 64
ohmm, i have written, it should be order by modified date,
any way i have done it
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: sql query issue
 
Similar Threads
Getting java.sql.SQLException. Why?
Display the sequence numbers on the output rows of a select in Oracle 10g
Need help in an query development
how to select random record from cursor
Complicated SQL query help