Dumb database question
stenson - July 21, 2008 - 18:41
Hi, I am new to Drupal. I have done some web development in PHP, trying to get into Drupal, am reading what is available on this site and some of the great Drupal devt books. I have a really dumb SQL question -- why are queries written like this:
SELECT n.title, n.body, n.created FROM {node} n WHERE n.uid = $uid LIMIT 0, 10;
That is, what is the "n." doing? What does the "n" after the {node} table do?
Thanks!

That's an alias. Because
That's an alias. Because tables in drupal can have anything as their prefix, we wrap table names in {} and then refer to them by aliases. Aliases are particularly useful when doing more complex queries such as joins and subqueries and whatnot. They allow you to do:
n.title
instead of
{node}.title
Basically they're a convenience feature.
Got it, thanks vm.
Got it, thanks vm.