469,342 Members | 5,580 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,342 developers. It's quick & easy.

SQL in asp

I have problem with a sql query..

My query looks like this:

strSql = "SELECT Topic.name, Topic.topic_id, [Topic].[level],
Topic.content_type_id, Topic.visible, Topic.external_link,
Topic.more_content, Topic.content_link, Topic.list_link,
Content_Type.admin_file_name, content_Type.description ";
strSql += "FROM content_Type RIGHT JOIN Topic ON
content_Type.content_type_id = Topic.content_type_id "
strSql += "ORDER BY Topic.hierarchy;";
But what I want to do is join in a secound table called ''menu''.
The 2 fields I want to join in is ''menu.topic_id'' and ''menu.language_id''

How can I join them in the same FROM query like this: menu.topic_id =
Topic.topic_id
If I understand tis right, I have to use two joins in the same FROM
sentence?
Christopher Brandsdal
Jul 19 '05 #1
7 1283
On Fri, 23 Jan 2004 13:11:32 +0100, "Christopher Brandsdal"
<ch***********@c2i.net> wrote:
I have problem with a sql query..

My query looks like this:
You should always specify the database or language, since some Access
SQL statments won't work in MS-SQL Server and vice versa. And Oracle
always bites me on syntax. :)
strSql = "SELECT Topic.name, Topic.topic_id, [Topic].[level],
Topic.content_type_id, Topic.visible, Topic.external_link,
Topic.more_content, Topic.content_link, Topic.list_link,
Content_Type.admin_file_name, content_Type.description ";
strSql += "FROM content_Type RIGHT JOIN Topic ON
content_Type.content_type_id = Topic.content_type_id "
strSql += "ORDER BY Topic.hierarchy;";
But what I want to do is join in a secound table called ''menu''.
The 2 fields I want to join in is ''menu.topic_id'' and ''menu.language_id''

How can I join them in the same FROM query like this: menu.topic_id =
Topic.topic_id
If I understand tis right, I have to use two joins in the same FROM
sentence?


Unless I miss what you're doing, wouldn't an implicit JOIN and a WHERE
clause work on this? Something like:

SELECT Topic.name, Topic.topic_id,
[Topic].[level],Topic.content_type_id, Topic.visible,
Topic.external_link,Topic.more_content, Topic.content_link,
Topic.list_link,Content_Type.admin_file_name,
content_Type.description,menu.topic_id,menu.langua ge_id
FROM Topic, content_Type, menu WHERE content_Type.content_type_id =
Topic.content_type_id AND menu.topic_id =Topic.topic_id
ORDER BY Topic.hierarchy

Jeff
Jul 19 '05 #2
"Christopher Brandsdal" <ch***********@c2i.net> wrote in message
news:eI****************@tk2msftngp13.phx.gbl...
I have problem with a sql query..

My query looks like this:

strSql = "SELECT Topic.name, Topic.topic_id, [Topic].[level],
Topic.content_type_id, Topic.visible, Topic.external_link,
Topic.more_content, Topic.content_link, Topic.list_link,
Content_Type.admin_file_name, content_Type.description ";
strSql += "FROM content_Type RIGHT JOIN Topic ON
content_Type.content_type_id = Topic.content_type_id "
strSql += "ORDER BY Topic.hierarchy;";
But what I want to do is join in a secound table called ''menu''.
The 2 fields I want to join in is ''menu.topic_id'' and ''menu.language_id''
How can I join them in the same FROM query like this: menu.topic_id =
Topic.topic_id


Perhaps something like this is what you're looking for:

SELECT
Topic.name,
Topic.topic_id,
Topic.level,
Topic.content_type_id,
Topic.visible,
Topic.external_link,
Topic.more_content,
Topic.content_link,
Topic.list_link,
Content_Type.admin_file_name,
content_Type.description,
menu.language_id
FROM
menu
INNER JOIN
(
content_Type
RIGHT JOIN
Topic
ON
content_Type.content_type_id = Topic.content_type_id
)
ON
menu.topic_id = Topic.topic_id
ORDER BY Topic.hierarchy
Now, just trim it down into a string variable, and I *think* that's what
you're looking for (though it's hard to say for sure).

Regards,
Peter Foti
Jul 19 '05 #3
as an aside...
strSql += "ORDER BY Topic.hierarchy;";


what sort of syntax is this? (+=)

I have not seen this before but it fails on my asp rig here. I suspect I
might be barking up the wrong tree here coz the ";" at the end of the line
suggests it is SQL syntax...
Jul 19 '05 #4
He's using JScript.

Bob Lehmann

"UncleWobbly" <he***@talk21.com> wrote in message
news:40*********************@lovejoy.zen.co.uk...
as an aside...
strSql += "ORDER BY Topic.hierarchy;";


what sort of syntax is this? (+=)

I have not seen this before but it fails on my asp rig here. I suspect I
might be barking up the wrong tree here coz the ";" at the end of the line
suggests it is SQL syntax...

Jul 19 '05 #5
"+=" is javascript, among other things, and serves the same purpose as
"strSQL = strSQL & ". The semi-colon is also javascript, and is wholly
unnecessary when writing in that language except to separate statements on
the same line.

"UncleWobbly" <he***@talk21.com> wrote in message
news:40*********************@lovejoy.zen.co.uk...
as an aside...
strSql += "ORDER BY Topic.hierarchy;";


what sort of syntax is this? (+=)

I have not seen this before but it fails on my asp rig here. I suspect I
might be barking up the wrong tree here coz the ";" at the end of the line
suggests it is SQL syntax...

Jul 19 '05 #6
William Morris wrote on 23 jan 2004 in
microsoft.public.inetserver.asp.general:
The semi-colon is also javascript, and is wholly
unnecessary when writing in that language except to separate
statements on the same line.


Also very useful helping you all to recognize the OP code was jscript.

;-}

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #7
ah right... thanks... silly me, when it said asp in the title I jumped to
conclusions...
"UncleWobbly" <he***@talk21.com> wrote in message
news:40*********************@lovejoy.zen.co.uk...
as an aside...
strSql += "ORDER BY Topic.hierarchy;";


what sort of syntax is this? (+=)

I have not seen this before but it fails on my asp rig here. I suspect I
might be barking up the wrong tree here coz the ";" at the end of the line
suggests it is SQL syntax...

Jul 19 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by William C. White | last post: by
2 posts views Thread by Albert Ahtenberg | last post: by
3 posts views Thread by James | last post: by
reply views Thread by Ollivier Robert | last post: by
1 post views Thread by Richard Galli | last post: by
4 posts views Thread by Albert Ahtenberg | last post: by
1 post views Thread by inderjit S Gabrie | last post: by
2 posts views Thread by Jack | last post: by
3 posts views Thread by Sandwick | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.