Can I use Views query in my custom code or not? Through views I am getting result perfectly in update preview. But when I use the same query in my custom code, its not working as expected. Do I need to do any modification in code or do I need to do any configuration in views so that I can get a query which should be executed through code also. Any help will be appreciated.
For example code is here: 

SELECT node.nid AS nid,
   node_uc_product_kits.nid AS node_uc_product_kits_nid,
   node_uc_product_kits.language AS node_uc_product_kits_language
 FROM node node 
 LEFT JOIN uc_product_kits uc_product_kits ON node.nid = uc_product_kits.product_id
 LEFT JOIN node node_uc_product_kits ON uc_product_kits.nid = node_uc_product_kits.nid
 WHERE (node_uc_product_kits.status = 1) AND (node.nid = 1 )


In code:

$ord_weight = db_result(db_query("SELECT node.nid AS nid,
   node_uc_product_kits.nid AS node_uc_product_kits_nid,
   node_uc_product_kits.language AS node_uc_product_kits_language
 FROM node node 
 LEFT JOIN uc_product_kits uc_product_kits ON node.nid = uc_product_kits.product_id
 LEFT JOIN node node_uc_product_kits ON uc_product_kits.nid = node_uc_product_kits.nid
 WHERE (node_uc_product_kits.status = 1) AND (node.nid = 1 )"));
print_r ($ord_weight-&gt;num_rows);
Long story shory, if you run the same query that the views module runs, you will get the same result.

If you are getting a different result this means that you


Don't run the same query (where do you get the views query from)
Don't provide the same dynamic variables if any is used


You should also note that Views has it's own magic variables in views, that only works in views, like ****CURRENT_LANGUAGE**** which maps to the current language.

You should also note that views does a lot of work in the theme layer to output data. Getting the same data from SQL doesn't mean that the actual output will be the same.