I have used sql for a while but never to any advanced degree I would very much appreciate some help. I have 3 tables:

member, member_details and reg_options

member holds all of a member's details like email, password, username and it has a primary key called id. member_details has 4 columns: id, member_id, option_id and value. reg_options has a number of columns all containg data for each of the options available at registration which link to the member_details.

so: a member with an id of 1 might have several records in member details all with member_id = 1 and each with a different option_id and all with their own value. The option id is relative to the reg_option which will give the name of what the option is and which type of members the option is available to and the text to use when displaying on different screens.

I need to construct a query, for example; to select all the members that have answered yes to option 1, yes to 2 and no to 3.

I really hope somebody can understand what I am trying to achieve because I haven't explained it very well. Many thanks to anyone who can help

Paul

Paul,

select a.id,b.name,c.option from member a, member_details b and reg_options b where a.id=b.id and a.id=c.id
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.