CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Problems with Complex SQL and sub query?

Print topic Send  topic

Author Message
csierra

Posts: 123
Posted: 12/25/2006, 2:46 PM

Hi everyone! I need help as follows, my db is MS Jet 4.0, have 1 table called tbContenidos and a query called qryContenidos, that´s all I have in my db. Now, I have a inner relation within this one table tbContenidos, have a primary key (IdC) and a second column called IdP, wich stands for IdParent... IdP points to the same table, constraint to IdC. What is *NOT* working in CCS 3.1 is using, or pretend to use a URL variable in the subquery.

The following SQL statement is used as a datasource for a simple grid component

Let me show: this works

SELECT qryContenidos.IdC, qryContenidos.IdP, qryContenidos.PrePath, qryContenidos.Fecha_creacion, qryContenidos.Nombre, qryContenidos.Titulo_corto, qryContenidos.Titulo_largo, qryContenidos.Intro, qryContenidos.Articulo, qryContenidos.Nota, qryContenidos.img_Menu, qryContenidos.img_Thumb, qryContenidos.img_Arte, qryContenidos.link_pc_od, qryContenidos.link_pc_dd, qryContenidos.link_c_od, qryContenidos.link_c_dd, qryContenidos.vd, qryContenidos.vh  
FROM qryContenidos  
WHERE (qryContenidos.IdP=(SELECT tbLookForIdP.IdP  
FROM tbContenidos AS tbLookForIdP  
WHERE tbLookForIdP.IdC=14 AND tbLookForIdP.IdP Is Not Null))  

However, what I need and does *not* work is:

SELECT qryContenidos.IdC, qryContenidos.IdP, qryContenidos.PrePath, qryContenidos.Fecha_creacion, qryContenidos.Nombre, qryContenidos.Titulo_corto, qryContenidos.Titulo_largo, qryContenidos.Intro, qryContenidos.Articulo, qryContenidos.Nota, qryContenidos.img_Menu, qryContenidos.img_Thumb, qryContenidos.img_Arte, qryContenidos.link_pc_od, qryContenidos.link_pc_dd, qryContenidos.link_c_od, qryContenidos.link_c_dd, qryContenidos.vd, qryContenidos.vh  
FROM qryContenidos  
WHERE (qryContenidos.IdP=(SELECT tbLookForIdP.IdP  
FROM tbContenidos AS tbLookForIdP  
WHERE tbLookForIdP.IdC=varIdC AND tbLookForIdP.IdP Is Not Null))  

Please note that where it says varIdC I have tried [@IdC], @IdC, IdC and accordingly have set the options in the SQL editor to match varIdC to a URL parameter, unsuccessfully.

Please note that both work on MS Access and plain ASP, so there is no pittfall in my SQL

Any ideas are very very much appreciated

Thanks

Carlos


_________________
Yes! I Can!!!
View profile  Send private message
Edd


Posts: 547
Posted: 12/25/2006, 3:16 PM

if "IdC" is a defined parameter then it sould be {IdC}

Edd
_________________
Accepting and instigating change are life's challenges.

http://www.syntech.com.au
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.