| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |
|

07-30-04, 14:05
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 494
|
|
|
database/asp - join tables - what kind is this one?
|
|
I have a set of 66 tables which are the 66 books of the bible. When I perform a "search" I want the search to go through all the 66 tables. What category is this considered?
|
|

08-01-04, 01:56
|
|
Useless...
|
|
Join Date: Jul 2003
Location: SoCal
Posts: 721
|
|
Quote:
|
Originally Posted by gilgalbiblewhee
I have a set of 66 tables which are the 66 books of the bible. When I perform a "search" I want the search to go through all the 66 tables. What category is this considered?
|
If you can do a stored procedure, that would be best. But why do you have to go through all 66 tables? Shouldn't the user select what types of data they want to search?
In SQL, you can also use the "UNION" clause between statements to join the result sets together. The only catch is that each statement must have the same result string (same number of columns with the same column names).
__________________
That which does not kill me postpones the inevitable.
|
|

08-01-04, 08:08
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
|
|
|
|
Quote:
|
Originally Posted by gilgalbiblewhee
I have a set of 66 tables which are the 66 books of the bible. When I perform a "search" I want the search to go through all the 66 tables. What category is this considered?
|
this is in the category of "sub-optimal design"
you will need 66 queries, which could be combined with UNION, but nevertheless each table wouyld be queries separately
by far, a better approach here would be one table instead of 66
|
|

08-03-04, 18:44
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 494
|
|
|
66 tables
I would rather have 66 tables because I want to leave the option or set of options to the viewer.
Can the come in an "if" statement? If so how would the code be written?
|
|

08-03-04, 19:04
|
|
Useless...
|
|
Join Date: Jul 2003
Location: SoCal
Posts: 721
|
|
leave the option to do what? why don't you put them all in one table, and have a column that designates what type of data this is.. then you can simply include that data code, or combination of data codes (based upon user selections), in your query.. I like that idea much better...
__________________
That which does not kill me postpones the inevitable.
|
|

08-03-04, 19:21
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 494
|
|
|
Ok I already have one db like that
|

08-03-04, 19:31
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
|
|
that page works very easily with one table
each book gets its own id, and i would suggest sequential numbers 1 through 66, if in fact that's how many there are (sorry, don't know)
your radio buttons (The entire King James Bible, or Your selection of books) would be used to tailor the sql
(nice, by the way, how the "entire" option grays out the checkboxes for the various books)
if selected individual books are checked, you pass those id numbers to the query, as in
SELECT ...
FROM bibletable
WHERE ...
AND bookid in ( 3, 24, 47 )
|
|

08-03-04, 19:41
|
|
Useless...
|
|
Join Date: Jul 2003
Location: SoCal
Posts: 721
|
|
Ok.. take all 66 tables, find a common schema between them all, and create a new table (based on that common schema), and add a new column called "recordType". It'll be a character field.. how long is up to you, but 2 characters should be enough. Now when you insert from the 66 tables into the one table, you'll include the record type (Example: table "book" may have a recordType of "bk", and psalm might be "ps", etc).
Now take your radio buttons and apply the recordType values to their respective radio buttons (or checkboxes for that matter - this is what you'd use if you want to be able to query multiple record types at the same time).
In your ASP, you'd take the recordType from the form and apply that to your SQL:
SQL = "select * from bibleTable where query LIKE '%" & Request.Form("Query") & "%' AND recordType = '" & Request.Form("recType") & "'"
Now, if you use checkboxes, you'll have to Split the Request.Form("recType") value on the "," character into an array, then loop through it adding multiple "OR recordType..." clauses to the SQL
Edit: I may be off on my radio button names, my office blocks tripod, but the idea is roughly the same
__________________
That which does not kill me postpones the inevitable.
|
Last edited by Seppuku; 08-03-04 at 19:54.
|

08-03-04, 19:51
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
|
|
nice post, Seppuku
book number, book code, recordType -- it doesn't really matter, does it
(omigod, did i just accidentally open up the surrogate-versus-natural can of worms?  )
.
Quote:
|
... then loop through it adding multiple "AND recordType..." clauses to the SQL
|
OR, shurely

|
|

08-03-04, 19:53
|
|
Useless...
|
|
Join Date: Jul 2003
Location: SoCal
Posts: 721
|
|
|
__________________
That which does not kill me postpones the inevitable.
|
|

08-03-04, 19:59
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 494
|
|
|
how to keep 001,002...
I want to convert the column number to 001,002,003, 004 but it automatically converts to 1,2,3,4. If I use the search to search for numbers example:
search 1
result would be 1, 10,11,12,13...
But if I would search 001
result would be 001
|
|

08-04-04, 00:34
|
|
Useless...
|
|
Join Date: Jul 2003
Location: SoCal
Posts: 721
|
|
the field is probably a character field then... you should make sure it's a number field..
__________________
That which does not kill me postpones the inevitable.
|
|

08-04-04, 01:02
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 494
|
|
|
i've pasted from excel 2000
Is there a easy way to fix that by Excel or MSAccess?
By the way I'm doing what you said and it's easier than I thought. Thanks.
|
|

08-04-04, 01:26
|
|
Useless...
|
|
Join Date: Jul 2003
Location: SoCal
Posts: 721
|
|
Quote:
|
Originally Posted by gilgalbiblewhee
Is there a easy way to fix that by Excel or MSAccess?
|
If you're doing this in Access, all you should need to do is change the column type to an integer.
Quote:
|
Originally Posted by gilgalbiblewhee
By the way I'm doing what you said and it's easier than I thought. Thanks.
|
Isn't normalization a wonderful thing? You'll save yourself a lot of headache this way.
__________________
That which does not kill me postpones the inevitable.
|
|

08-04-04, 01:38
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 494
|
|
|
can you be more specific on recType?
I'm a newbie and I don't know the terms like looping.
This is what I have so far:
Quote:
<%@ LANGUAGE="VBSCRIPT" %>
<html>
<head>
<TITLE>bible.asp</TITLE>
</head>
<body>
<%
SqlBible = "SELECT * FROM bible WHERE query LIKE '%" & Request.Form("Query") & "%' AND recordType = '" & Request.Form("recType") & "'"
Set dbGlobalWeb = Server.CreateObject("ADODB.Connection")
dbGlobalWeb.Open("kjv")
dim mySearch, iCounter
mySearch=Request.QueryString("mySearch")
iCounter = 0
'number
If request.QueryString("book")="yes" then
SqlBible = SqlBible & "book LIKE '%" & mySearch & "%'"
iCounter = iCounter + 1
end if
'number
If request.QueryString("book_spoke")="yes" then
If iCounter > 0 Then
SqlBible = SqlBible & " AND "
End If
SqlBible = SqlBible & "book_spoke LIKE '%" & mySearch & "%'"
iCounter = iCounter + 1
end if
'text
If request.QueryString("book_title")="yes" then
If iCounter > 0 Then
SqlBible = SqlBible & " AND "
End If
SqlBible = SqlBible & "book_title LIKE '%" & mySearch & "%'"
iCounter = iCounter + 1
end if
'number
If request.QueryString("chapter")="yes" then
If iCounter > 0 Then
SqlBible = SqlBible & " AND "
End If
SqlBible = SqlBible & "chapter LIKE '%" & mySearch & "%'"
iCounter = iCounter + 1
end if
'number
If request.QueryString("chapter_spoke")="yes" then
If iCounter > 0 Then
SqlBible = SqlBible & " AND "
End If
SqlBible = SqlBible & "chapter_spoke LIKE '%" & mySearch & "%'"
iCounter = iCounter + 1
end if
'number
If request.QueryString("verse")="yes" then
If iCounter > 0 Then
SqlBible = SqlBible & " AND "
End If
SqlBible = SqlBible & "verse LIKE '%" & mySearch & "%'"
iCounter = iCounter + 1
end if
'number
If request.QueryString("verse_spoke")="yes" then
If iCounter > 0 Then
SqlBible = SqlBible & " AND "
End If
SqlBible = SqlBible & "verse_spoke LIKE '%" & mySearch & "%'"
iCounter = iCounter + 1
end if
'number
If request.QueryString("text_data")="yes" then
If iCounter > 0 Then
SqlBible = SqlBible & " AND "
End If
SqlBible = SqlBible & "text_data LIKE '%" & mySearch & "%'"
iCounter = iCounter + 1
end if
Set rsGlobalWeb = Server.CreateObject("ADODB.Recordset")
rsGlobalWeb.Open SqlBible, dbGlobalWeb, 3%>
<%
If rsGlobalWeb.BOF and rsGlobalWeb.EOF Then%>
<h2 align="center">We did not find a match!</h2>
<%Else%>
<%If Not rsGlobalWeb.BOF Then%>
<h2>These are the results:</h2>
<table BORDER="0" width="100%" cellpadding="3">
<tr>
<th bgcolor="#800000"><font face="Arial" color="#FFFFFF">Book </font></th>
<th bgcolor="#800000"><font face="Arial" color="#FFFFFF">Book Spoke </font></th>
<th bgcolor="#800000"><font face="Arial" color="#FFFFFF">Book Title </font></th>
<th bgcolor="#800000"><font face="Arial" color="#FFFFFF">Chapter </font></th>
<th bgcolor="#800000"><font face="Arial" color="#FFFFFF">Chapter Spoke</font></th>
</td>
<th bgcolor="#800000"><font face="Arial" color="#FFFFFF">Verse </font></th>
<th bgcolor="#800000"><font face="Arial" color="#FFFFFF">Verse Spoke</font></th>
</td>
<th bgcolor="#800000"><font face="Arial" color="#FFFFFF">Text </font></th>
</tr>
<%
Do While Not rsGlobalWeb.EOF
%>
<tr>
<td><%=rsGlobalWeb("book")%>
</td>
<td><%=rsGlobalWeb("book_spoke")%>
</td>
<td><%=rsGlobalWeb("book_title")%>
</td>
<td><%=rsGlobalWeb("chapter")%>
</td>
<td><%=rsGlobalWeb("chapter_spoke")%>
</td>
<td><%=rsGlobalWeb("verse")%>
</td>
<td><%=rsGlobalWeb("verse_spoke")%>
</td>
<td><%=rsGlobalWeb("text_data")%>
</td>
</tr>
<% rsGlobalWeb.MoveNext
Loop
%>
</table>
<%End If%>
<%End If%>
<%
rsGlobalWeb.Close
dbGlobalWeb.Close
%>
</body>
</html>
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|