473,411 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

select count with table join

229 100+
Hi, I wonder if anyone knows how to do this. I need to get info from another table and cannot get anything to work.
I tried
Expand|Select|Wrap|Line Numbers
  1.  ' set rst=conn.execute("select Watchedprofileid , p.pdjobtitle,M.WatchinguserID from tblWatches M INNER join tblother P ON M.WatchinguserID = P.UserId  where (Select Count(*) from tblWatches where WatchinguserID = " & rs("userID"))
I also cannot get it to return results greater than 5, for example. I added >5

where WatchinguserID = " & rs("userID") > 5)

for example but that didnt work.


Expand|Select|Wrap|Line Numbers
  1. <%    
  2.  dim rst
  3. 'on error resume next
  4.  
  5. set rst=conn.execute("Select count(*) from tblWatches where WatchinguserID = " & rs("userID"))
  6.  
  7. if rst(0)> 0 then
  8.         response.Write "<b> watching " & rst(0) & " </b>"
  9.     end if
  10.     rst.close
  11. %> 
Thanks in advance for any help.
Richard
Jul 6 '11 #1
2 2492
code green
1,726 Expert 1GB
You need to expalin what you are trying to do. This meaningless
Hi, I wonder if anyone knows how to do this. I need to get info from another table and cannot get anything to work.
Post SQL code and not VB.
Jul 6 '11 #2
nbiswas
149 100+
How about this

Expand|Select|Wrap|Line Numbers
  1. ' set rst=conn.execute
  2.  
  3. ("
  4.  
  5. select 
  6.  
  7. Watchedprofileid 
  8. , p.pdjobtitle
  9. ,M.WatchinguserID 
  10.  
  11. from tblWatches M 
  12.  
  13. INNER join tblother P 
  14.  
  15. ON M.WatchinguserID = P.UserId  
  16.  
  17. where M.WatchinguserID > 5
  18.  
  19. And M.WatchinguserID = " & rs("userID")
  20.  
Hope this helps..
Jul 6 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Floris van den Berg | last post by:
Is something like the following possible? SELECT products.id, count(*) as counter FROM products, keywords WHERE keywords.keyword in ("bla","hi","hello") AND counter > 2; Can't get it to work...
7
by: JP Belanger | last post by:
I have a question on select count(), which may betray my lack of database knowledge. Here goes. I have java code driving a transaction which goes like this: select count(*) from table ...
4
by: Alec Christie | last post by:
Hi All, I want to Count the number of members in my database that have specific criteria, such as Blue eyes, or Brown hair. I have fields named Hair and Eyes, and others ofcourse, but I just...
5
by: Daniel Wetzler | last post by:
Dear MS SQL Experts, I have to get the number of datasets within several tables in my MSSQL 2000 SP4 database. Beyond these tables is one table with about 13 million entries. If I perform a...
2
by: db2udbgirl | last post by:
If I perform a select count(*) from tred.order_delivery query will it internally perform a full table scan to determine the row count for the following scenario case 1: There is a primary key on a...
1
by: chiume | last post by:
First thank you very much for all your helps, and pls. Ok, this is what I am trying to do:, 1) I am trying to get the number of employees that has completed all their online training within...
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
3
by: ret4rt | last post by:
Hello. I have a database with movies similar with imdb and i want to find out which directors have directed both thriller and drama movies. The output i want is like this "DIR_NAME,amount of...
14
by: lewindletter | last post by:
Hi If I do Begin transaction Stmt 1: select count(*) from tableA If the count is zero, then proceed to the following Stmt 2: insert "something" to tableA Stmt 3: insert "something" to...
5
by: FFMG | last post by:
Hi, I was running a test on a table with 50000 rows. When I do: $sql = "SELECT * FROM TABLE"; $result = mysql_query($sql); $total = mysql_num_rows(result); I get a 'run out of memory...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.