Selecting nodes by content type and value of a custom field
In Views, you could do this:


Create a view, filter on node TYPE and node PUBLISHED
Create an argument/contextual filter using your CUSTOM FIELD
In Fields, select NID (and/or TITLE or whatever you want to work with in the node(s))


Preview the view, putting FILTERONTHIS in the arguments/contextual filter area.

Look at the SQL it generated in the Preview and cut/paste it into whatever you need, substituting FILTERONTHIS for a variable of your chosing. Or, save the view and then use views_get_view_result() to access the result.