Page not found return false Im using a custom query to display some content. 
This query uses url arguments as MySQL variables.

Usually when I create a link with the variables the page does not exist and it returns a 404 error.

Is there a way of creating a page on certain urls to avoid getting an "page not found"?

EDIT:
To be more specific

The query is something like 

SELECT * WHERE node.type = '.arg(0).' AND node_data_field_type.field_type = '.arg(1).'


The url intended would be: example.com/exhibition/speacial_feature or 
example.com/program/speaker_series

The link exhibition/speacial_feature or program/speaker_series are not found.
Supposing that example.com is a site running Drupal, what Drupal does when you try to access  example.com/exhibition/speacial_feature is:


Verify exhibition/speacial_feature is a path alias
Verify there is a menu that uses exhibition/speacial_feature as path
Verify a module define a menu callback for exhibition/speacial_feature


If none of the conditions is verified, then Drupal returns a 404 error.

In your case, as you want to execute code when a path is entered, you need to create a module that defines a menu callback.

function mymodule_menu() {
  $items = array();

  $items['mymodule/%/%'] = array(
    'page callback' =&gt; 'mymodule_abc_view',
    'page arguments' =&gt; array(1, 2),
  );

  return $items;
}

function mymodule_page_view($first, $second) {
  // Execute the query, and show the result.
} 


The code for hook_menu() I shown is the minimum required; see hook_menu() for more information.

As also noted from Berdir, you don't concatenate input given from a user to obtain the query to execute, as that causes SQL injection. You need to use query parameters, which are supported in any Drupal version. Also, with static queries, the name of the database tables are surrounded by { and }.