aspose file tools*
The moose likes JDBC and the fly likes What Is the Correct Syntax? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "What Is the Correct Syntax?" Watch "What Is the Correct Syntax?" New topic
Author

What Is the Correct Syntax?

JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
I am searching a database, order the search result by some criterion supplied by users and ASC/DESC is also supplied by user's selection. How do I write the query statement?
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
String query = "SELECT thread_id, message_receiver, message_sender, article_title FROM message_thread WHERE message_receiver = '" + memberName + "' ORDER BY " + sortCriterion + " " + order;
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: What Is the Correct Syntax?