I have designed a view and I see this query in the preview section:

SELECT node.nid AS nid, 
       node_data_field_crm_history_brokerid.field_crm_history_brokerid_value AS node_data_field_crm_history_brokerid_field_crm_history_brokerid_value, 
       node.language AS node_language, 
       node.type AS node_type, 
       node.vid AS node_vid, 
       node_data_field_crm_history_brokerid.field_crm_history_caseid_value AS node_data_field_crm_history_brokerid_field_crm_history_caseid_value, 
       node_data_field_crm_history_brokerid.field_crm_history_dateadded_value AS node_data_field_crm_history_brokerid_field_crm_history_dateadded_value, 
       node_data_field_crm_history_brokerid.field_crm_history_entrydesc_value AS node_data_field_crm_history_brokerid_field_crm_history_entrydesc_value 
FROM node node 
LEFT JOIN content_type_crm_history node_data_field_crm_history_brokerid ON node.vid = node_data_field_crm_history_brokerid.vid 
WHERE node.type in ('crm_history')

What does vid mean here?

Actually I need this because when I try to insert a simple rule to insert a row in the crm_history using this query:

$result = db_query("INSERT INTO {content_type_crm_history} (vid, nid, field_crm_history_caseid_value, field_crm_history_brokerid_value, field_crm_history_dateadded_value, field_crm_history_entrydesc_value) VALUES (" . $node->nid . ", " . $node->vid . ", " . $caseid . ", " . $brokerid . ", " . $dateadded . ", '" . t($entrydesc) . "')");

It does populate the database table but it doesn't show in the view. It shows only the view when I add via the create content page.

3 Answers 3


Unfortunately, vid can mean multiple things. That's not ideal, but I have not seen it causing problems (other than mild confusion now and then).

In the context of nodes, it means 'version id'. For every node in the node table, Drupal can save multiple versions in the node_revisions table. The version id is the unique identifier in the node_revisions table. (This is the vid you see in your query.)

In the context of taxonomy, vid means 'vocabulary id'. A vocabulary is a collection of related terms. Every vocabulary has a unique id.

In the context of the Views module, vid means 'view id'.

On a different note, you should not be adding nodes to the database with custom queries. The better method is to create a node object and let drupal write it to the database using node_save().


From the Drupal node object reference page, node->vid is the revision id of the current version of the node.

Node content isn't stored directly in the node table but in the node_revisions table. There's a good explanation of the table structures on this page.


vid is the revision id. In Drupal, every node can have multiple revisions. If you aren't using revisions, then the nid (node ID) will equal the vid.

  • But, when not using revisions, don't count on nid always equaling vid!
    – Greg
    Jan 25, 2010 at 19:43
  • can any one give examples of query to insert data in to the content so that i can see the contents in the view.. urgent guys
    – rakeshakurathi
    Jan 26, 2010 at 15:02
  • @rakeshakurathi - Look at the source code for Node Clone. One of the few things it does is insert new nodes, so it should be easy to locate the relevant code in its source. drupal.org/project/node_clone
    – Greg
    Jan 26, 2010 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.