File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases 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 and Relational Databases
Bookmark "What Is the Correct Syntax?" Watch "What Is the Correct Syntax?" New topic

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;
I agree. Here's the link:
subject: What Is the Correct Syntax?
jQuery in Action, 3rd edition