Jump to content

filtering down results total with a series of options


glennn.php

Recommended Posts

i have a large publication database where i need to filter down the results with a series of options such as 'state', 'year', 'affiliation', etc. (9 total) - where might i find a good example of a script that would do something like this?

 

i'm adequate with simple queries, but i'm not sure if something like this is going to involve JOINs or something... perhaps this is just a bunch of conditions using AND...?

 

thanks for any help you can offer...

 

Regards,

GN

Link to comment
Share on other sites

Why not a simple where clause?

 

SELECT * from tablename WHERE state='value' AND affiliation='value'

 

Just keep adding another AND each time you want to specify another option.

 

You can also use OR instead of AND e.g.

 

SELECT * from tablename WHERE state='value' OR affiliation='value'

Link to comment
Share on other sites

yeah, that's what i was thinking, but the database is designed as such:

 

 



--
-- Table structure for table 'rel_affiliation'
--

CREATE TABLE rel_affiliation (
  affiliation int(3) NOT NULL,
  affil_text varchar(255) collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (affiliation)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table 'rel_calendar'
--

CREATE TABLE rel_calendar (
  calendar int(1) NOT NULL,
  calendar_text varchar(10) collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (calendar)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table 'rel_carnegie'
--

CREATE TABLE rel_carnegie (
  cc2001 int(3) NOT NULL,
  cc_description varchar(255) collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (cc2001)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table 'rel_emphasis'
--

CREATE TABLE rel_emphasis (
  emphasis int(255) NOT NULL,
  emphasis_text varchar(20) collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (emphasis)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table 'rel_inst_type'
--

CREATE TABLE rel_inst_type (
  inst_type int(2) NOT NULL,
  inst_type_text varchar(30) collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (inst_type)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;


 

etc...

 

this is where i think i'm going to need to see some example code...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.