close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Show details with advance recordset

Thread began 7/02/2011 11:27 am by wbrooks199805 | Last modified 7/10/2011 2:18 pm by CraigR | 2904 views | 26 replies |

wbrooks199805

Show details with advance recordset

I have 2 tables. One "members" and the other "naics". I have 6 different items in members (serviceone, servicetwo, servicethree, servicefour, servicefive, servicesix) and trying to call in the naicsTitle from naics. I know how to call in one item from the naics table but when I try 2 it doesn't work.

I know this isn't the answer below in select but the first one will work for naicsTitle but after that I am stuck.

SELECT naicsTitle, serviceone, servicetwo, servicethree, servicefour, servicefive, servicesix
FROM members
JOIN naics ON members.serviceone = naics.naicsNum AND members.servicetwo = naics.naicsNum

Sign in to reply to this post

CraigRBeta Tester

can you explain what kind of data each table holds and the relationship between them ?

is the naics table essentially a reference table ?

can members hold more than one naics code ?

Sign in to reply to this post

wbrooks199805

questions and answers

can you explain what kind of data each table holds and the relationship between them ?

RE: One is members database. Second is a division of their company

is the naics table essentially a reference table ?

RE: It is a dropdown menu of all their divisions
Table Name: naics
naicsNum, naicsTitle

can members hold more than one naics code ?
RE: Members can have up to 6 divisions. If you look at the select area you can see that serviceone, servicetwo, etc. are part of the members table and those would be the divisions.

Sign in to reply to this post

CraigRBeta Tester

I think I see what you are trying to do.

You probably need to re-think your table structure

Your members table doesn't need the naics number columns
Create a new table 'membernaics' with the following columns..

membernaicsid, (PK, auto)
memberid
naicsid

say, member 1 has naics 7, 8 and 9

the data would be

membernaicsid : memberid : naicsid
1:1:7
2:1:8
3:1:9

to retrieve the naicstitle for each member

SELECT member, naicstitle FROM members JOIN members ON membernaics.memberid = membernaics.memberid JOIN naics ON membernaics.naicsid = naics.naicstitle

This also allows you to have as many naics items per member as you wish

Sign in to reply to this post

wbrooks199805

I'll give it go

Thanks..will give it a shot tomorrow.
Wait a minute..FROM members JOIN members? That doesn't make sense to me..can you do that?

Sign in to reply to this post

wbrooks199805

Not a unique table

I was right. You can't use because you can't have FROM members and JOIN members because its not a unique table.

Any other ideas? I have tried a few different ways of doing this but can't get any of them to work.

Sign in to reply to this post

CraigRBeta Tester

sorry, for the typos.

not certain of your field names but try this..

SELECT member, naicstitle FROM members JOIN membernaics ON members.memberid = membernaics.memberid JOIN naics ON membernaics.naicsid = naics.naicsid

Sign in to reply to this post

wbrooks199805

screen shot

I changed it to the correct names but the values are not coming back correctly when I tested the server. It should have different values in the title for the naicsTitle as they are different.

SELECT memNum, naicsTitle
FROM members JOIN membernaics ON members.memNum = membernaics.memberid JOIN naics ON membernaics.naicsid = naics.naicsNum

Sign in to reply to this post

wbrooks199805

Okay so this works but now..

This works.

SELECT memNum, naicsTitle, servicesone, servicetwo, servicethree, memberid, naicsid
FROM members JOIN membernaics ON members.memNum = membernaics.memberid JOIN naics ON membernaics.membernaicsid = naics.naicsNum

But now I need to have the update and input page work. How do I set up that record set?
This needs to input that info into the membernaics table?

This is what I have now.
SELECT naicsNum, naicsTitle
FROM naics

Sign in to reply to this post

CraigRBeta Tester

OK, just to ensure we're not talking at cross purposes...


i have created a database with 3 tables, as laid out in the attached file, which you need to unzip

using phpmyadmin, add the tables and query them as follows...

SELECT membername, naicsdescription FROM member JOIN membernaics ON member.memberid = membernaics.memberid JOIN naics ON membernaics.naicsid = naics.naicsid

or for all of the fields...

SELECT * FROM member JOIN membernaics ON member.memberid = membernaics.memberid JOIN naics ON membernaics.naicsid = naics.naicsid

you result set should look like this

Attached Files
naics.zip
Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...