RE: MySQL Inner Join issue (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


BeTheBall -> RE: MySQL Inner Join issue (10/13/2005 10:42:16)

OK, what happens if you run it without the WHERE clause, i.e.:

fp_sQry="SELECT tbltopic.forum_id, tbltopic.topic_id, tblthread.thread_id, tblthread.topic_id FROM tbltopic INNER JOIN tblthread ON tbltopic.topic_id = tblthread.topic_id"




sentinel -> RE: MySQL Inner Join issue (10/13/2005 11:00:41)

when i run without the where i get results




BeTheBall -> RE: MySQL Inner Join issue (10/13/2005 11:33:08)

OK, what about this:

fp_sQry="SELECT tbltopic.forum_id, tbltopic.topic_id, tblthread.thread_id, tblthread.topic_id FROM tbltopic INNER JOIN tblthread ON tbltopic.topic_id = tblthread.topic_id AND tbltopic.forum_id = 1"




BeTheBall -> RE: MySQL Inner Join issue (10/13/2005 11:52:15)

Sorry, I missed one of your earlier posts. You are saying this works?

fp_sQry="SELECT tbltopic.forum_id, tbltopic.topic_id, tblthread.thread_id, tblthread.topic_id FROM tbltopic INNER JOIN tblthread ON tbltopic.topic_id = tblthread.topic_id WHERE tbltopic.forum_id = 1"




sentinel -> RE: MySQL Inner Join issue (10/13/2005 12:26:03)

Yes. INserting the forum_id manually works fine. Its trying to get it to take the variable that is the issue




BeTheBall -> RE: MySQL Inner Join issue (10/13/2005 12:56:54)

<grasping at straws>

See if this makes a difference:

fp_sQry="SELECT tbltopic.forum_id, tbltopic.topic_id, tblthread.thread_id, tblthread.topic_id FROM tbltopic INNER JOIN tblthread ON tbltopic.topic_id = tblthread.topic_id WHERE tbltopic.forum_id = "& Request.Form("forum_id")

If not, please post the code for the page that submits to this one, i.e., where the forum_id is inserted.




sentinel -> RE: MySQL Inner Join issue (10/13/2005 13:05:16)

Got this error:

Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/forum_choice.asp, line 13, column 18
fp_sQry="fp_sQry="SELECT tbltopic.forum_id, tbltopic.topic_id, tblthread.thread_id, tblthread.topic_id FROM tbltopic INNER JOIN tblthread ON tbltopic.topic_id = tblthread.topic_id WHERE tbltopic.forum_id = "& Request.Form("forum_id")
-----------------^



Here is the page that submits to the page

<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Forum</title>
</head>

<body>

<table width="100%" border="1">
  <thead>
  </thead>
  <tbody>
    <!--#include file="_fpclass/fpdblib.inc"-->
<% if 0 then %>
<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database Results component on this page is unable to display database content. The page must have a filename ending in '.asp', and the web must be hosted on a server that supports Active Server Pages.</div>");
    </SCRIPT>
<% end if %>
<%
fp_sQry="SELECT * FROM tblforum"
fp_sDefault=""
fp_sNoRecords="<tr><td colspan=5 align=left width=""100%"">No records returned.</td></tr>"
fp_sDataConn="Database1"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_sColTypes="&Forum_ID=19&Forum_Desc=201&Forum_Name=201&Forum_Group=201&Security=201&"
fp_iDisplayCols=5
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="_fpclass/fpdbrgn1.inc"-->
<tr>
      <td>
      <%=FP_FieldVal(fp_rs,"Forum_ID")%> </td>
      <td>
      <%=FP_FieldVal(fp_rs,"Forum_Desc")%> </td>
      <td>
      <a href="forum_Choice.asp?Forum_ID=<%=FP_FieldURL(fp_rs,"Forum_ID")%>">
      <%=FP_FieldVal(fp_rs,"Forum_Name")%></a> </td>
      <td>
      <%=FP_FieldVal(fp_rs,"Forum_Group")%> </td>
    </tr>
    <!--#include file="_fpclass/fpdbrgn2.inc"-->
</tbody>
</table>

</body>

</html>




BeTheBall -> RE: MySQL Inner Join issue (10/13/2005 13:32:53)

Wish I had asked for that code about 25 posts ago. You have no form. The id is being passed via a query string, so instead of Request.Form, you must use Request.QueryString. See if this does the job:

fp_sQry="SELECT tbltopic.forum_id, tbltopic.topic_id, tblthread.thread_id, tblthread.topic_id FROM tbltopic INNER JOIN tblthread ON tbltopic.topic_id = tblthread.topic_id WHERE tbltopic.forum_id = "& Request.QueryString("Forum_ID")




sentinel -> RE: MySQL Inner Join issue (10/13/2005 15:17:06)

Get an unterminated string constant




Spooky -> RE: MySQL Inner Join issue (10/13/2005 15:18:07)

Post the current code?




BeTheBall -> RE: MySQL Inner Join issue (10/13/2005 16:36:07)

Maybe:

fp_sQry="SELECT tbltopic.forum_id, tbltopic.topic_id, tblthread.thread_id, tblthread.topic_id FROM tbltopic INNER JOIN tblthread ON tbltopic.topic_id = tblthread.topic_id WHERE tbltopic.forum_id = "& Request.QueryString("Forum_ID") &""




sentinel -> RE: MySQL Inner Join issue (10/14/2005 11:11:57)

Hey there... sorry I just got back to my office.

The last chunk of code did not work either.

But I did throw something at it today that did work. I changed the query around and this is what I came up with on accident. I say on accident because I did it without knowing how or why I did it.

SELECT tbltopic.forum_id, tbltopic.topic_id, tbltopic.subject, tblthread.thread_id, tblthread.topic_id, tblthread.username, tblthread.message_date FROM tbltopic INNER JOIN tblthread ON tbltopic.subject = tblthread.subject WHERE Forum_ID = ::forum_id::

This works for now but is not the solution because it doesnt make any sense to base the join of of SUBJECT. If someone creates identical subjects then ill get weird results, but maybe I can work around it.

Thanks for everything. Sorry for the headache!




BeTheBall -> RE: MySQL Inner Join issue (10/14/2005 11:52:06)

No problem, although I agree with you that the current solution makes no sense. I wonder by chance if the topic_id in one table is a different data type than the one in the other? Very bizarre.




Page: <<   < prev  1 [2]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
7.421875E-02