How to limit dropdown list to options based on 'in use' rows from lookup table, for webpage using php and postgresql
Killian Driscoll <[email protected]> Tue, 29 Dec 2015 17:23:18 +0100
| Newsgroups | gmane.comp.db.postgresql.php |
|---|---|
| Message-ID | <CAL64pZNGxLQZ=haCh4Fu0H49VtjGPH8g7ced5Te4gorB1j7ciA@mail.gmail.com> |
--94eb2c035260091d5b05280bd8a2 Content-Type: text/plain; charset=UTF-8 I have a table country with a lookup table to country_type. table country country_id (pk), col2, col3, country_type_id (fk) integer lookup table country_type country_type_id (pk), type_name varchar My lookup table has 50 country types, but only 20 are 'in use' in the current db (with the rest possibly used later as the db expands). On the webpage I am creating (I am using a php generator) I can set it up to add a filter by country type based on the country type_name varchar - so one can view the country types by name rather than the id integer - but all 50 types are listed. I only want the 20 that currently 'in use' (not sure if this is the best way to describe it) and therefore relevant to searches/filters (i.e. I don't want to see a "There are no records to display" message). What WHERE condition can I use to achieve this? Killian Driscoll --94eb2c035260091d5b05280bd8a2 Content-Type: text/html; charset=UTF-8 <div dir="ltr"><div class="" itemprop="text"> <p>I have a table country with a lookup table to country_type. <br></p><p>table country <br></p><p>country_id (pk), col2, col3, country_type_id (fk) integer</p> <p>lookup table <br></p><p>country_type country_type_id (pk), type_name varchar</p><p>My lookup table has 50 country types, but only 20 are 'in use' in the current db (with the rest possibly used later as the db expands). On the webpage I am creating (I am using a php generator) I can set it up to add a filter by country type based on the country type_name varchar - so one can view the country types by name rather than the id integer - but all 50 types are listed. <br></p><p>I only want the 20 that currently 'in use' (not sure if this is the best way to describe it) and therefore relevant to searches/filters (i.e. I don't want to see a "There are no records to display" message). <br></p><p>What WHERE condition can I use to achieve this?</p><p>Killian Driscoll<br></p></div></div> --94eb2c035260091d5b05280bd8a2--