navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

SELECT COUNT AND THE OTHER FIELDS IN DATABASE

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> SELECT COUNT AND THE OTHER FIELDS IN DATABASE
Page: [1]
 
William Angold

 

Posts: 4
Joined: 7/5/2002
Status: offline

 
SELECT COUNT AND THE OTHER FIELDS IN DATABASE - 7/5/2002 15:11:52   
Could anyone tell me what is wrong with this query

fp_sQry=" SELECT COUNT(ID) , * FROM jobs"

I get this error

Database Results Error
Description: [Microsoft][ODBC Microsoft Access Driver] Cannot group on fields selected with ' *' .
Number: -2147217900 (0x80040E14)
Source: Microsoft OLE DB Provider for ODBC Drivers

Are there any ways around this

Thanks

William
porsche944

 

Posts: 366
Joined: 3/6/2002
From: Regina Canada
Status: offline

 
RE: SELECT COUNT AND THE OTHER FIELDS IN DATABASE - 7/5/2002 17:26:21   
This is yours:
fp_sQry=" SELECT COUNT(ID), * FROM jobs"
this is what i think:
fp_sQry=" SELECT COUNT(ID) FROM jobs"
I am not very god with SQL but i did manage to get my count query going a short while ago

This will count the number of jobs you have in the database.(I think)

< Message edited by porsche944 -- 7/4/2002 5:27:35 PM >

(in reply to William Angold)
ASPPlayground

 

Posts: 122
Joined: 6/25/2002
From: Toronto, Canada
Status: offline

 
RE: SELECT COUNT AND THE OTHER FIELDS IN DATABASE - 7/5/2002 17:58:21   
in this case you will need correlated subquery.

Like this:

" SELECT * , (SELECT Count(ID) FROM jobs) FROM jobs" 


but this is cumbersome because you will count all rows again and again. I will suggest that you use two separated queries for that.

_____________________________

Samuel Chou

ASPPlayground.NET Developer

(in reply to William Angold)
William Angold

 

Posts: 4
Joined: 7/5/2002
Status: offline

 
RE: SELECT COUNT AND THE OTHER FIELDS IN DATABASE - 7/6/2002 5:08:31   
I may be being stupid but how would I use the statement

" SELECT * , (SELECT Count(ID) FROM jobs) FROM jobs"

To shop the number from the count(id) part of the statement. I want to use it in an if then statement

William

(in reply to William Angold)
Spooky

 

Posts: 26606
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: SELECT COUNT AND THE OTHER FIELDS IN DATABASE - 7/6/2002 5:12:24   
What is the actual outcome you are after?

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to William Angold)
William Angold

 

Posts: 4
Joined: 7/5/2002
Status: offline

 
RE: SELECT COUNT AND THE OTHER FIELDS IN DATABASE - 7/6/2002 5:14:06   
I want to be able to use the count staement so that if it is 0 a form will be displayed if not the records from the select * will be displayed.


William

(in reply to William Angold)
Spooky

 

Posts: 26606
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: SELECT COUNT AND THE OTHER FIELDS IN DATABASE - 7/6/2002 10:02:16   
The way Sam mentioned will work - the last column value of the returned recordset will be the count value.

However, for your task, you may be best performing a simple database select query.

You would have 2 possible outcomes - records exist, or they don' t.
If they do, then fine, the records will be written to the page. However, the result of no records existing, would mean instead of writing " No records exist" , you would write your form in its place.

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to William Angold)
William Angold

 

Posts: 4
Joined: 7/5/2002
Status: offline

 
RE: SELECT COUNT AND THE OTHER FIELDS IN DATABASE - 7/6/2002 10:24:56   
Ho do you wirite HTML in the place where " No records Exists" is. When I try doing anthing it comes up with an error. DO you encase it in " " .

William

(in reply to William Angold)
no_mac_jack

 

Posts: 295
From: Washington state, USA
Status: offline

 
RE: SELECT COUNT AND THE OTHER FIELDS IN DATABASE - 7/7/2002 1:25:17   
You should be able to put HTML in there, but you have to replace each double quote (" ) with two in a row so that you don' t throw off the ASP coding that' s printing it. For example, this...

<p align=" center" >

would become this...

<p align=" " center" " >

Also, sometimes it will only let you enter a certain number of characters. However, this can usually be overcome if you write out the code in notepad or something and then copy & paste it. Lastly, your code all has to be on one line.

Let me know if it' s still giving you trouble...Good luck!

~no_mac_jack

(in reply to William Angold)
SilverDragon

 

Posts: 1
Joined: 10/10/2003
Status: offline

 
RE: SELECT COUNT AND THE OTHER FIELDS IN DATABASE - 10/10/2003 9:32:52   
You could try the following code:


if not myrecordset.eof then
response.write "All The HTML code you want here!"
else
response.write "NO DATA RETURNED FROM DATABASE"
end if

I think that is what you are trying to do.....

(in reply to William Angold)
hzarabet

 

Posts: 1540
From: New Milford CT USA
Status: offline

 
RE: SELECT COUNT AND THE OTHER FIELDS IN DATABASE - 10/10/2003 12:43:51   
I have used a META Redirect in the "No records returns" spot and it works.

Redirect to a form page.

_____________________________

http://www.SigningsHotline.com lists EVERY upcoming athlete autograph appearance in the US and Canada

(in reply to SilverDragon)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> SELECT COUNT AND THE OTHER FIELDS IN DATABASE
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts