Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JDBC and Relational Databases
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
JDBC and Relational Databases
What Is the Correct Syntax?
JiaPei Jen
Ranch Hand
Posts: 1309
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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?
public Collection getBeans( String memberName, String sortCriterion, String order ) throws IllegalArgumentException, DatabaseException, BadInputException { ....... ....... String query = "SELECT thread_id, message_receiver, message_sender, article_title FROM message_thread WHERE message_receiver = '" + memberName + "' ORDER BY + '" sortCriterion + '" + " " + '"order + "'"; ....... ....... }
Ali Gohar
Ranch Hand
Posts: 572
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
String
query = "SELECT thread_id, message_receiver, message_sender, article_title FROM message_thread WHERE message_receiver = '" + memberName + "' ORDER BY " + sortCriterion + " " + order;
The overall mission is to change the world. When you've done that, then you can read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Present A List By Groups (More Related to Design)
Please Point Out My Mistakes
Array Index Out Of Bounds Exception: 0 ( Mistake with My MySQL "count"?)
To Get the Number of Matches Found in the Database
Search Engine Submitting Problem
More...