title: TRUNCATE table only if it exists (to avoid errors)
body: <p>I have a .sql file that clear cached data in a mysql schema before export because the cached data in these tables is useless when I import the export file to a different server. I use this script on multiple sites, but in some instances certain table don't exist because they are not required. How do I only truncate a table in MySQL if only that table exist? </p>
  
  <pre><code>TRUNCATE accesslog;
  TRUNCATE cache;
  TRUNCATE cache_block;
  TRUNCATE cache_bootstrap;
  TRUNCATE cache_customfilter;
  TRUNCATE cache_field;
  TRUNCATE cache_filter;
  TRUNCATE cache_form;
  TRUNCATE cache_image;
  TRUNCATE cache_menu;
  TRUNCATE cache_metatag;
  TRUNCATE cache_page;
  TRUNCATE cache_path;
  TRUNCATE cache_token;
  TRUNCATE cache_update;
  TRUNCATE cache_views;
  TRUNCATE cache_views_data;
  TRUNCATE watchdog;
  </code></pre>
  
  <p>Thanks in advance. </p>