glennn.php Posted August 29, 2008 Share Posted August 29, 2008 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 Quote Link to comment Share on other sites More sharing options...
KPH71 Posted August 29, 2008 Share Posted August 29, 2008 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' Quote Link to comment Share on other sites More sharing options...
glennn.php Posted August 29, 2008 Author Share Posted August 29, 2008 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... Quote Link to comment Share on other sites More sharing options...
fenway Posted August 29, 2008 Share Posted August 29, 2008 Sounds like you need some cross joins.... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.