Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 passing names to query
 New Topic  Topic Locked
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 6

Alfred
Senior Member

USA
1527 Posts

Posted - 29 July 2003 :  17:00:12  Show Profile  Visit Alfred's Homepage
I have a table in my Access database called "member_medals" with these 3 text fields:

ID
MEMBER_ID
MEDAL_ID

If I would like to query that table now, inorder to display the member names on a page, how do I go about it?

All I know how to do is "select" the id numbers, as in:
select * from member_medals , etc..., but that will not give me the names!

Alfred
The Battle Group
CREDO

D3mon
Senior Member

United Kingdom
1685 Posts

Posted - 29 July 2003 :  17:28:12  Show Profile  Visit D3mon's Homepage
Which field contains the member names?


Snitz 'Speedball' : Site Integration Mod : Friendly Registration Mod
"In war, the victorious strategist only seeks battle after the victory has been won"
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 29 July 2003 :  17:29:56  Show Profile
you need to do an inner join on the members table.

Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 29 July 2003 :  17:47:27  Show Profile  Visit Alfred's Homepage
D3mon: the names are not in that table, only the member_IDs from FORUM_Members.

Nikkol: How do I do an "inner join"?

Alfred
The Battle Group
CREDO

Edited by - Alfred on 29 July 2003 17:48:47
Go to Top of Page

laser
Advanced Member

Australia
3859 Posts

Posted - 29 July 2003 :  20:05:05  Show Profile
Alfred, you use Access db's right ? and this is a brand new page ? to display every user's name and their medals ?

The easiest way (if using Access) is to create a new Query, and play around with it until you get the output that you want. Then switch to SQL view, and cut & paste the SELECT into your ASP code. I'll have a look at the code tonight, but there's people here that can do inner joins with one hand
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 29 July 2003 :  22:50:40  Show Profile  Visit Alfred's Homepage
Well, I fooled around in the help files of Access, and they talk about inner joins there.
But, as usual, the guidance is obscure and confusing:
"In query design view (wherever that is!) drag the field from one table into the field of the other table".
I somehow managed to open the two tables next to each other, but nothing let me drag it between them.

Alfred
The Battle Group
CREDO
Go to Top of Page

GauravBhabu
Advanced Member

4288 Posts

Posted - 30 July 2003 :  00:04:03  Show Profile
strSql = "SELECT M.MEMBER_ID, M.MEDAL_ID, M1.M_NAME " & _
         "FROM MEMBER_MEDALS M " & _
         "INNERJOIN FORUM_MEMBERS M1 ON M1.MEMBER_ID = M.MEMBER_ID;"
Go to Top of Page

laser
Advanced Member

Australia
3859 Posts

Posted - 30 July 2003 :  00:06:22  Show Profile
I wouldn't even do that - open Query Designer and add the two tables. Then just choose the fields you want to double-clicking on them to create the query you want. Then execute the query (the red ! button) and check the results. *IF* the results come out wierd then you need to check the links between the tables.

To get into Query Mode, open your database and there should be a menu on the left that goes Tables, Queries, Forms, Modules (or something along those lines). Click on Query then Design new Query
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 30 July 2003 :  01:01:11  Show Profile  Visit Alfred's Homepage
Somehow I got the two tables combuned, then I went into SQL mode and saw this:
quote:

SELECT FORUM_MEMBERS.M_NAME, MEMBER_MEDALS.ID, MEMBER_MEDALS.member_ID, MEMBER_MEDALS.medal_ID
FROM FORUM_MEMBERS INNER JOIN MEMBER_MEDALS ON FORUM_MEMBERS.MEMBER_ID = MEMBER_MEDALS.member_ID;


Got to build on that in the morning - thanks for now, both of you!

Alfred
The Battle Group
CREDO
Go to Top of Page

Anacrusis
Junior Member

USA
219 Posts

Posted - 30 July 2003 :  07:51:45  Show Profile  Visit Anacrusis's Homepage  Send Anacrusis an AOL message
quote:
Originally posted by Alfred

I have a table in my Access database called "member_medals" with these 3 text fields:

ID
MEMBER_ID
MEDAL_ID



Those are all text fields? Will he run into problems joining member_medals.MEMBER_ID (text) to FORUM_MEMBER.MEMBER_ID (int) ?

The Internet ClubHouse
www.internet-clubhouse.com
Go to Top of Page

laser
Advanced Member

Australia
3859 Posts

Posted - 30 July 2003 :  07:58:48  Show Profile
How can you tell they are text fields ?
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 30 July 2003 :  11:22:10  Show Profile  Visit Alfred's Homepage
quote:
Originally posted by GauravBhabu

strSql = "SELECT M.MEMBER_ID, M.MEDAL_ID, M1.M_NAME " & _
         "FROM MEMBER_MEDALS M " & _
         "INNERJOIN FORUM_MEMBERS M1 ON M1.MEMBER_ID = M.MEMBER_ID;"


I tried this in the new page, and when I link to it I get htis error:
quote:
Error Type:
Microsoft VBScript runtime (0x800A01C2)
Wrong number of arguments or invalid property assignment: 'DisplayMedalIcon'
/BG/forums/decorated.asp, line 24
The text file for "decorated.asp" is here: http://www.ggholiday.com/bg/forums/decorated.txt

PS.: I have installed the page on a manual basis for now, so something can be seen in the meantime, and give you an idea of what I am trying to do.
But it does of course not get populated from the database yet - I have to keep an eye on the data and upload changes for now.
From here:
http://www.ggholiday.com/bg/forums/DEFAULT.ASP
the link "honored members" will bring up this page:http://www.ggholiday.com/bg/forums/decorated.ASP

Alfred
The Battle Group
CREDO

Edited by - Alfred on 31 July 2003 13:02:14
Go to Top of Page

Anacrusis
Junior Member

USA
219 Posts

Posted - 31 July 2003 :  15:26:52  Show Profile  Visit Anacrusis's Homepage  Send Anacrusis an AOL message
quote:
Originally posted by laser

How can you tell they are text fields ?

quote:

I have a table in my Access database called "member_medals" with these 3 text fields:



I just assumed... I'm probably wrong though.

The Internet ClubHouse
www.internet-clubhouse.com

Edited by - Anacrusis on 31 July 2003 15:29:59
Go to Top of Page

laser
Advanced Member

Australia
3859 Posts

Posted - 31 July 2003 :  18:01:35  Show Profile
Oops, sorry Anacrusis - I forgot Alfred said text. Alfred, if they really are text I doubt that the inner join will work.

OK Alfred, looking at your code I see that the medals on decorated.asp are different to the medals on members.asp. How are you going to do this ? I guess by having a small & large version of each medal but I haven't seen that in the table yet

Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 31 July 2003 :  21:08:55  Show Profile  Visit Alfred's Homepage
I use the same images of the medals for all pages, just sizing them as needed on the page.
So far you can only see a few on members.asp of all those that are in the member_medals table.
That should not present a problem, should it?

Alfred
The Battle Group
CREDO

Edited by - Alfred on 31 July 2003 22:18:41
Go to Top of Page

laser
Advanced Member

Australia
3859 Posts

Posted - 01 August 2003 :  01:14:36  Show Profile
I'll double-check later, but I was sure that the filenames on decorated.asp and members.asp are different - (aren't they ?)
Go to Top of Page
Page: of 6 Previous Topic Topic Next Topic  
Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.62 seconds. Powered By: Snitz Forums 2000 Version 3.4.07