473,508 Members | 2,140 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

select statement where

229 New Member
Hi, I am having trouble with a select statement and not sure how to phrase it.


I have many links on one page like this.

I need that when you click on one postcardid link all the other postcardids associated with the author of that link are displayed on another page page.

Expand|Select|Wrap|Line Numbers
  1. href="artschooldirectory.asp?PostCardID=<%=rsCard("PostCardID")%>"
This is the code on the other page. At the moment it only displays one result, ie the individual postcardid from the link. Each postcardid is by an author. I need it to display all the postcardids from the one author.
I dont know if that is clear but any help woulr be great.
Thanks
richard




Expand|Select|Wrap|Line Numbers
  1. lngPostCardID=Clng(Request("PostCardID"))
  2. If lngPostCardID <> "" Then
  3.  
  4.     Set connPostCardSoft=Server.CreateObject("ADODB.Connection") 
  5.     connPostCardSoft.Open PostCardSoftConnectString
  6.     Set rsCard=Server.CreateObject("ADODB.Recordset")
  7.     rsCard.CursorLocation = 3
  8.     SQLQuery="Select PostCardID,DefaultHeadline,CardDescription,DefaultMessage,Author,PictureURL,BackgroundImageURL,ThumbnailHTML,Rnd([PostCardID])  From tblGreetingPostCards where PostCardID=" & Clng(lngPostCardID) & " ORDER BY Author"
  9.     rsCard.Open SQLQuery, connPostCardSoft
  10.        rsCard.PageSize = 600
  11.        intPageCount = rsCard.PageCount
  12.  
  13.        If rsCard.EOF=True Then
  14.         Response.Write "<p>No artists found in database for this category."
  15.         Response.End
  16.     End If
  17. End If
Apr 30 '08 #1
2 1252
DrBunchman
979 Recognized Expert Contributor
Hi Richard,

Try changing your SQL string to something like the following:

Expand|Select|Wrap|Line Numbers
  1. SQLQuery = " SELECT PostCardID, DefaultHeadline, CardDescription, DefaultMessage, Author, PictureURL, BackgroundImageURL, ThumbnailHTML, Rnd([PostCardID]) FROM tblGreetingPostCards WHERE AuthorID IN (SELECT AuthorID FROM tblGreetingPostCards WHERE PostCardID = " & Clng(lngPostCardID) & ")"
This query is selecting every row where the AuthorID is the same as the AuthorID of the selected postcard (I've assumed a column called AuthorID which you can obviously change to fit your db).

Does this make sense? Let me know how it goes.

Dr B
Apr 30 '08 #2
fran7
229 New Member
Dear Dr B,
Tht worked a treat, thanks for that and understanding exactly what I wanted.
Richard
Apr 30 '08 #3

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

Similar topics

21
5215
by: John Fabiani | last post by:
Hi, I'm a newbie and I'm attempting to learn howto create a select statement. When I use >>> string1='18 Tadlock Place' >>> cursor.execute("SELECT * FROM mytest where address = %s",string1) All...
1
4461
by: brett | last post by:
Here is my SQL string: "SELECT to_ordnum, to_orddate," _ & "(SELECT SUM((DDPROD.pr_stanmat * DDPROD.pr_prfact) * (DOBOM2.b2_quant * DDORD.or_quant)) FROM DDPROD INNER JOIN DOBOM2 ON...
4
6924
by: Elroyskimms | last post by:
Using SQL 2000... tblCustomer: CustomerID int CompanyName varchar(20) HasRetailStores bit HasWholesaleStores bit HasOtherStores bit tblInvoiceMessages:
3
5708
by: dumbledad | last post by:
Hi All, I'm confused by how to replace a SELECT statement in a SQL statement with a specific value. The table I'm working on is a list of words (a column called "word") with an index int...
2
1571
by: GIS Analyst | last post by:
Hi to all I wish to be able to have a standard select statement which has additional fields added to it at run-time based on supplied parameter(s). ie declare @theTest1 nvarchar(10) set...
4
2230
by: 001 | last post by:
Hello, The select statement needs only 1 second to complete the query. But the update statement spends 30 minutes. Why? SELECT STATEMENT: declare @IDate smalldatetime select @IDate=col001...
3
6425
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
1
3647
by: Grant McLean | last post by:
Hi First a simple question ... I have a table "access_log" that has foreign keys "app_id" and "app_user_id" that reference the "application_type" and "app_user" tables. When I insert into...
6
13742
by: Bob Stearns | last post by:
I am getting duplicate rows back from a select distinct statement of the form: SELECT DISTINCT 'jhough', '000111', t0.bhid FROM (SELECT lots of good stuff) t0 LEFT OUTER JOIN another_table ...
0
5603
FishVal
by: FishVal | last post by:
Hereby I'm proposing a way of convinient work with properties containing SQL Select statements, particulary RowSource property of ComboBox and ListBox. The usual way is the following. Private...
0
7228
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
7128
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
7393
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
7502
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
5635
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
4715
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
769
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
426
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.