Click to See Complete Forum and Search --> : ORDER BY in Java..


Blind Melon
April 27th, 2008, 06:41 PM
Hey all, I've got a question. How would one ORDER BY *insert column name* in Netbeans? I know how to use it in the "execute command" part for the database itself...

SELECT HOLIDAY, CUSTOMER, DATE FROM WAITLIST ORDER BY DATE

Which then orders it by date, but I want to have a function (in one of my classes) execute that command so it reorganizes the database table from that class, but I'm not sure how to set up the function... I thought something like a simple void function and:

orderWait.executeQuery();

would work, but obviously not. Any help would be appreciated.


Also, I am using prepared statements to access the database, so that's not the problem either.

dlorde
April 28th, 2008, 04:28 AM
... I want to have a function (in one of my classes) execute that command so it reorganizes the database table from that classCan you explain what you mean a little more clearly - perhaps a couple of examples might help...

If you want to make the column name in the 'ORDER BY' clause a variable, you just tack a String variable into your SQL expression:String sqlExpression = "... ORDER BY " + columnName;A prudent question is one-half of wisdom...
F. Bacon