Select Count Statement

After i have SLECT COUNT(X) as "A" from....

I want to issue a condition to check for the number of records. this is what i do

Code:

SQL = "select count(*) as "A" from..."
set objRec = objConn.execute(SQL)

if objRec("A") = "3" then

is this statement correct? Doesn't seems working.

View Replies


ADVERTISEMENT

Select Count(*)

I have tried everything possible and still I cant understand why one of the codes work.
This one works, uses a Form to get required info. Code:

View Replies View Related

Select Count(*) ??

I need to set a variable to a select count(*) so I can check if something exists.
For example I have:

SQL = Select field from table where a = adf and b = fdad
set rs = conn.execute(sql)

variablec = rs("c")

But I want to do it with a count so i can use:
If variablecount > 1 Then
newvariable = true

down the line.

View Replies View Related

Select COUNT ?

My problem is using the SELECT COUNT to count the total of call in students. I get the correct count when they is no zero record. But when zero record returns, the count got mix up.. Code:

View Replies View Related

Select Count

How do I count the number of students in a table where their next_Action field is equal to "Follow up". Plus, how do I display out the result?

View Replies View Related

Select Count

Code:

dim sumv, mySQL, conntemp, rstemp
mySQL="SELECT COUNT(*) FROM crminfo where open = '1'"
call getFromDatabase(mySQL, rstemp, "sort2cat.asp")
if not rstemp.EOF then
response.write rstemp.count
end if

View Replies View Related

Getting A Count With SQL Statement

I have the following SQL Statement that keeps giving me an error:

SQL_ITEMS5 = "SELECT Ratings.Category AS CATEGORY1, Count(Reviews.Rating) AS CountOfCategory FROM Ratings LEFT JOIN Reviews ON (Ratings.Category = Reviews.Rating AND Reviews.cUserName = Request("UserName"))GROUP BY Ratings.Category"

Im trying to get a count of the number of records in the Reviews table that matches the records in the Ratings table for each User.

This is the error im getting:

Microsoft VBScript compilation error '800a0401'

Expected end of statement

And it points at the Request("UserName")

View Replies View Related

Select Count(*) Always Returns Zero

using mysql - vbscript and oledb provider

I have a table with 2 records

I do this in asp

rs.open "select count(*) as countervar from sqltable" ,oconn,1,1

response.write rs(0).value or response.write rs(0) gives zero and not 2 as to be expected

Also I would also like to be able to do calculations like this

rs.open "select 10 * 2 as result" ,oconn,1,1

response.write rs(0) also gives zero and not 20 as expected

can't this be done?

View Replies View Related

Select File Count

i have a bit of a weird question . I'm looking for a pull statement that pulls the number of files in a specific folder , But at the same time it wouldn't pull the number of pictures in this folder either . I have no idea how to write this code and I'm wondering if anyone could help me out?

View Replies View Related

Execute Sql Count Statement In Asp

In ASP page, if we want to retrive the number of rows in database: should we
use recordset object? Since this is not update, insert, delete, or select
statement

sqlStmt = "SELECT COUNT(*) from table1;"
Set objRS = Server.CreateObject("ADODB.RecordSet")
objRS.open sqlStmt, strConnect

But how do we can the value?

View Replies View Related

Canīt Get Select Count(*)... GROUP BY To Work

Iīm trying to build a forum of my own but have stumbled on my first problem as early as the opening page.

To the problem: I want to show a simple forum layout with tables looking something like
this:

Forum Name | Topics | Posts | Last Post
---------------------------------------------------
General | 1 | 4 | Webmaster, 09 Feb -06

To do this I use the following SQL;

sqlPosts = "SELECT Date, COUNT(Date) as NrOfPosts FROM ForumPosts WHERE
ForumID = " & rsForum("ForumID") & " GROUP BY Date ORDER BY Date DESC"

But this doesnīt give me the right numbers. Instead of showing Topics to
be 1 and Posts to be 4 it shows Topics to be 1 and Posts to 1.

But if I use a simpler sql, like this;

sqlPosts = "SELECT COUNT(Date) as NrOfPosts FROM ForumPosts WHERE
ForumID = " & rsForum("ForumID") & " ORDER BY Date DESC"

Then it works, but I canīt get any other info from the table, like date,
userid etc. Code:

View Replies View Related

Select Statement

how do you select all the fields in a table that do not contain any data?? I have tried the below and it wont work??

View Replies View Related

Select Statement

I am trying to display a feild from the table. But there is a Type Mismatch error that I am getting. Can anyone please take a look at my code to see what could be wrong.

The error that i am getting is:
Microsoft VBScript runtime error '800a000d'

Type mismatch

/jobapplicationnew.asp, line 1285
Line 1285 is highlighted.

Code:

View Replies View Related

Select Statement

following is my select statment code, works partially fine but the city search is not working.. i.e it gives me list of all hotels that start with the given words whereas it should give me hotels in the given city only. pls help me out. thanks

sSQL = "SELECT * " _
& "FROM [hotel] " _
& "WHERE hotel_name LIKE '%" & Replace(hotel_name, "'", "''") & "%' " _
& "OR hotel_name_e LIKE '%" & Replace(hotel_name, "'", "''") & "%' " _
& "and city = '"&city&"';"

View Replies View Related

Select Statement

the select statement as per the following relationships:

drop1id has 1 to 9 records.
drop2id has 1 to 65 records - FK drop1id will be 1 to 9
drop3id has 1 to 356 records - FK drop2id will be 1 to 65
drop4id has 1 to 356 records - FK drop3id will be 1 to 356.

I am not sure how to retreive the records based on their relationships.

View Replies View Related

Select Statement

does anyone know if its possible to look through a field in a database and see if it contains certain keywords?

i am using a database with a field called MainIssue and i want to see if it contains keywords and if it does, to display the contents. is there a command which would do the same thing as:

select * from maintable where field contains "keywords"

View Replies View Related

Select Statement

I am having problems with a select statement in asp with an access database.
I pull First and Last information from my form
First = Comes from form
Last = Comes from form
I have validated that the form information is being pulled this is where my problem lies.
Code:
SQL = "Select Listing where (FirstName =" & First & ") AND (LastName =" & Last & ")"
For some reason I can not pull the information for the database using this. If I take the AND (LastName =" & Last & ") out I can pull some of the information, but I am looking for a specific last name, first name entry.

View Replies View Related

Select Statement

i have the following tables in my Access database

info1, info2, info3...

all tables have the same columns with the same type of data.

code, description, activated etc.

now i ask the user to enter a code, and then it searches through all the tables for that code. the reason i broke it into smaller tables is there is 10s of thousands of records.
it should find the record that match with the entered code and then if the user wants to, he can edit the data, the date is then automatically saved into the record as well.

View Replies View Related

Select Like Statement

Some of my pages include paging where the variable starts with a certain letter. This worked fine in access but when I try to run it with mysql it says...

Microsoft OLE DB Provider for ODBC Drivers error '80040e37'

[MySQL][ODBC 3.51 Driver][mysqld-4.0.17-nt]You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT username, status FROM users WHERE username Like 'A%' OR

View Replies View Related

Select Statement

This is really simple but for some reason no recordset is returning. I can't get cat_1 to write. I have run the query against the database in Query Analyser and it runs fine.

Code:
Dim objConn
Set objConn = Server.CreateObject("ADODB.Connection") objConn.ConnectionString = "Driver={SQL Server};Server=nzlakldwhse;Database=Complaints;Uid=elkuser;Pwd=elk;"
objConn.Open

Dim objRS
Dim cat_id, cat_1, cat_2
set objRS = objConn.Execute("select cat_id, cat_1 from complaints.dbo.category a where a.cat_id = '"& request.form("cat_id") &"'")

response.Write(cat_1)
response.End

View Replies View Related

Select Statement

Code:

[advsearch = "Select * from img_inv where item_num like '%" & item_num &"%' or category = '" & category &"' order by item_num"



I want it to be able to search the db by like item number or exactly equal it a given category list.

View Replies View Related

SQL Statement Select

How do i get this to work, i have 3 colums forename, surname and groupname and a colum Genre. I want to select any of the 3 first colums for a name, where the Genre colum is X
this is the statment i have
Code:

"select * FROM autos WHERE forename LIKE '" & session("name") & "' OR surname LIKE '" & session("name") & "' OR groupname LIKE '" & session("name") & "' AND genre LIKE '" & session("genre") & "'"


this is what i get :-
select * FROM autos WHERE forename LIKE 'david' OR surname LIKE 'david' OR groupname LIKE 'david' AND genre LIKE 'Football'
giving David and 'session("name") and Football as session("football")

View Replies View Related

SELECT Statement

I've inherited a database with NULL values in it. I plan on fixing this problem, but for now I need to get this statement working.

cmd = "SELECT * FROM EmpInfo WHERE Interview <> NULL AND status IS NULL OR status <> 'D'"

I'm trying to pull information from the table that need to conform to two different rules. First, there needs to be a value in the INTERVIEW column.

Second, the column STATUS has to be NULL, there can be no D (for delete) in the record.

I can get it to pull the records following the conditions for STATUS, but not for INTERVIEW. I don't work with NULL values very often, so this one is throwing me for a loop.

How can I write that statement to pull only those records that are not NULL in one column, but NULL in another?

View Replies View Related

SELECT Statement

In my company one of the people who works for me has done this:

sqlText = "SELECT products.ProdID, productName, " _
& "productPrice, quantity from products, " _
& "itemsOrdered where " _
& "products.productID = itemsOrdered.productID "_
& "and itemsOrdered.orderID = " & intOrderID

I am just a little unsure what products.ProdID means when later on in the string there is the FROM products?

View Replies View Related

Select Statement

i give the users the option to choose between a daterange to get data from the database.

For example
(RADIO BUTTON) Last 7 days
(RADIO BUTTON) Last month
(RADIO BUTTON) Custom dates

Got the custom dates part to work, but how do i write my select function to select todays date and then go back seven days / 1 month(30days)?

View Replies View Related

Select Statement

In a select statement How do i select the last 10 records in a database?

View Replies View Related

Select Statement

I've got a client who needs some ASP's coded for a Unix server running ChiliSoft, (I had no say in the matter).

I'm banging my head against a wall with the following code:
[VBS]Set objRs = Server.CreateObject("ADODB.Recordset")
Set objRs.ActiveConnection = objConn
objRs.Open "Select * From tblDataBank_Summer Where DatabankID = " & intDatabankID, , adOpenStatic, adLockOptimistic, adCmdTable[/VBS]

I've used this coding elsewhere on other sites with no troubles, but here I keep getting:

ADODB.Recordset.1 error '80004005'

SQLState: 42000
Native Error Code: 1064
[TCX][MyODBC]You have an error in your SQL syntax near 'Select * From tblDataBank_Suummer Where DatabankID = 114 ' at line 1

View Replies View Related

Select Statement

how to do a select statemtn like below

SELECT * FROM table WHERE ID =" & strID & " AND Users LIKE " & strUserName

View Replies View Related

Select Statement

im in need of some guidence regarding select statements. is it possible to combine to select statements?reason for asking is i got this in my access mdb i have to queries one to get the specific member for witch i want the sum from and name is used as creteria then the secon queri is the sum it selfe by using grouped and name as creteria that works well but if i want this on a asp page it becomes little dificult.

well i cant see how can be done as i hoping some of u out there do i was thinking of combining the 2 so the first select gets the info then sum as secon select in a combined select statement i dunno if thats possible. or is there a way i could just use a select all from table and a asp function that can sumerize a field and then put that as a response.write?

View Replies View Related

2 Select Statement

Currently i am doing 2 select statement of SQL

select xxx into #temp

select xxx from tablA inner join #temp
... condition....
... condition....

and this hit error show that as attachment

anyone know y asp cant work with 2 select statement?

View Replies View Related

Select Statement

I keep getting an error when i execute the following statement?

SQL = "SELECT * FROM shop WHERE brand,size = '"& brand & "', '" & size & "'"

View Replies View Related

Select Statement

Why when I add the AND statement, this query doesnīt work? Am I wrong with my syntaxis?

SELECT ID, month, theyear FROM myDB where theyear = 2008 AND month = 1

If I only leave theyear or month it works. If I put AND it doesnīt.

View Replies View Related

Error In Select Statement Using Where And Between

Find below the error I get when the code below is executed

Code:

splitval = split(request.form("start")," ")
dep = splitval(0)

splitval1 = split(request.form("end")," ")
dep1 = splitval1(0)

"SELECT * FROM Info WHERE requestDate BETWEEN dep AND dep1 "

error:
No value given for one or more required parameters.

Can someone help correct the error in the code.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved