This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
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?
Similar Threads
Array Index Out Of Bounds Exception: 0 ( Mistake with My MySQL "count"?)
Present A List By Groups (More Related to Design)
Please Point Out My Mistakes
To Get the Number of Matches Found in the Database
Search Engine Submitting Problem