Simpel(?) SQL question for Access

Simpel(?) SQL question for Access

am 08.04.2005 10:31:44 von Bob The ASP Builder

I'm running a simpel SQL question towards an Accessdatabase where the
question is generic towards all my tabels in the database

Like this
MySql = "SELECT * from " & dbtable


This gives the result that called table (current value of dbtable)
returns all postings(rows) in rising order (ASC) sorted after first
column which is always the IDcolumn but with differen names.

I just want the result returned i falling order instead

Like this sort of (not the correct way though)


MySql = "SELECT * from " & dbtable & " " & " Order by " & dbtable(0) &
" " & " DESC "


whereiI then would like dbtable(0) to return the actual name for the
first column


Grateful for someones helpful hint on how to...

Bob

Re: Simpel(?) SQL question for Access

am 08.04.2005 11:46:28 von John Blessing

"Bob The ASP Builder" wrote in message
news:tnfc51tneb3trfsnlgisqa5qc9nklu7vvr@4ax.com...
>
> I'm running a simpel SQL question towards an Accessdatabase where the
> question is generic towards all my tabels in the database
>
> Like this
> MySql = "SELECT * from " & dbtable
>
>
> This gives the result that called table (current value of dbtable)
> returns all postings(rows) in rising order (ASC) sorted after first
> column which is always the IDcolumn but with differen names.
>
> I just want the result returned i falling order instead
>
> Like this sort of (not the correct way though)
>
>
> MySql = "SELECT * from " & dbtable & " " & " Order by " & dbtable(0) &
> " " & " DESC "
>
>
> whereiI then would like dbtable(0) to return the actual name for the
> first column
>

Select * trom " & dbtable & " order by 1 DESC"


Regards

John Blessing
jb@Lbesoftware.com
http://www.LbeHelpdesk.com - Help Desk software priced to suit all
businesses
http://www.room-booking-software.com - Schedule rooms & equipment bookings
for your meeting/class over the web.
http://www.lbetoolbox.com - Remove Duplicates from MS Outlook

Re: Simpel(?) SQL question for Access

am 08.04.2005 12:30:17 von Bob The ASP Builder

On Fri, 8 Apr 2005 10:46:28 +0100, "John Blessing"
wrote:

>"Bob The ASP Builder" wrote in message
>news:tnfc51tneb3trfsnlgisqa5qc9nklu7vvr@4ax.com...
>>
>> I'm running a simpel SQL question towards an Accessdatabase where the
>> question is generic towards all my tabels in the database
>>
>> Like this
>> MySql = "SELECT * from " & dbtable
>>
>>
>> This gives the result that called table (current value of dbtable)
>> returns all postings(rows) in rising order (ASC) sorted after first
>> column which is always the IDcolumn but with differen names.
>>
>> I just want the result returned i falling order instead
>>
>> Like this sort of (not the correct way though)
>>
>>
>> MySql = "SELECT * from " & dbtable & " " & " Order by " & dbtable(0) &
>> " " & " DESC "
>>
>>
>> whereiI then would like dbtable(0) to return the actual name for the
>> first column
>>
>
>Select * trom " & dbtable & " order by 1 DESC"
>
>
>Regards
>
>John Blessing
>jb@Lbesoftware.com
>http://www.LbeHelpdesk.com - Help Desk software priced to suit all
>businesses
>http://www.room-booking-software.com - Schedule rooms & equipment bookings
>for your meeting/class over the web.
>http://www.lbetoolbox.com - Remove Duplicates from MS Outlook
>
>
That didi it!!
Wasnt that amazingly simple?? THANK YOU - I have crawled the web and
several tutorials without finding this - so THANK YOU!!!!!

Re: Simpel(?) SQL question for Access

am 26.04.2005 00:48:12 von Bullschmidt

Yes, that was cool, and I didn't know it could be done like that either.

So in summary (from my limited testing):

This can be done to sort on the first field:
strSQL = "SELECT * FROM MyTable ORDER BY 1"

This can be done to sort on the second field:
strSQL = "SELECT * FROM MyTable ORDER BY 2"

But this cannot be done:
strSQL = "SELECT 1 FROM MyTable"

Best regards,
J. Paul Schmidt, Freelance ASP Web Developer
http://www.Bullschmidt.com
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...


*** Sent via Developersdex http://www.developersdex.com ***