Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

What Is the Correct Syntax?  RSS feed

 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String query = "SELECT thread_id, message_receiver, message_sender, article_title FROM message_thread WHERE message_receiver = '" + memberName + "' ORDER BY " + sortCriterion + " " + order;
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!