Wrox Programmer Forums
|
ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Pro Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 17th, 2003, 12:33 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default combine query in ASP

Hi,

How can use combine query in asp
what is the syntax error of following query?
problem in date (data type) how can use date query in asp to retrieve the records.

Date_recd and Date_revd is the date data type.


ssql = "select drawings.#date_recd#, drawings.#date_revd#, drawings.type, drawings.location, sectors.sect_area from drawings, sectors
where drawings.name = sectors.name and drawings.type in ('" & plt & "','" & util & "') " and sectors.sect_area in ('" & sa1 & "','" & sa2 & "') "
order by sectors.sect_area, drawings.type"


regards.

Mateen Martin
[email protected]
 
Old July 17th, 2003, 12:45 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 215
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You haven't actually told us what the syntax error message is.

However the voices in my head they told me that the # around the column names is a problem. Try removing them.

regards
David Cameron
 
Old July 17th, 2003, 03:17 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The #'s should only be used when you are testing for a date, not selecting it from the table. Try this SQL statement:

Code:
ssql = "SELECT drawings.date_recd, drawings.date_revd, drawings.type, " & _
"drawings.location, sectors.sect_area " & _
"FROM drawings, sectors " & _
"WHERE drawings.name = sectors.name " & _
"AND drawings.type IN ('" & plt & "', '" & util & "') " & _
"AND sectors.sect_area in ('" & sa1 & "', '" & sa2 & "') " & _
"ORDER BY sectors.sect_area, drawings.type"
If you wanted to add a condition to only select rows where the column drawings.date_recd was after 1st January 2000 then you could include " AND drawings.date_recd > #2000-01-01#" to the query.

Regards
Owain Williams
 
Old July 20th, 2003, 02:42 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your response.
this query display all records.
I want that if I select sect_area only,
what query will write in asp, I have to retrieve
records from two tables.

regards.

Mateen


Quote:
quote:Originally posted by owain
 The #'s should only be used when you are testing for a date, not selecting it from the table. Try this SQL statement:

Code:
ssql = "SELECT drawings.date_recd, drawings.date_revd, drawings.type, " & _
"drawings.location, sectors.sect_area " & _
"FROM drawings, sectors " & _
"WHERE drawings.name = sectors.name " & _
"AND drawings.type IN ('" & plt & "', '" & util & "') " & _
"AND sectors.sect_area in ('" & sa1 & "', '" & sa2 & "') " & _
"ORDER BY sectors.sect_area, drawings.type"
If you wanted to add a condition to only select rows where the column drawings.date_recd was after 1st January 2000 then you could include " AND drawings.date_recd > #2000-01-01#" to the query.

Regards
Owain Williams





Similar Threads
Thread Thread Starter Forum Replies Last Post
Combine two queries snufse SQL Server 2005 6 June 24th, 2008 09:42 PM
combine the nodes pravind XSLT 3 April 23rd, 2007 01:11 PM
Is it possible to combine two forms into one? malhyp Dreamweaver (all versions) 13 June 5th, 2006 07:29 AM
Best Way To Combine Reports ? jkirst BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 May 16th, 2005 09:56 AM
Combine 2 classes blur.kid JSP Basics 1 September 12th, 2003 04:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.