Skip to main content
3 of 3
edited tags
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

Make a direct database query

Basically I want to run this query against the current database and retrieve all node titles with node type of foo_type.

SELECT title FROM node WHERE type='foo_type' ORDER BY title ASC

How can I do this using db_query or any similar function? I tried doing the below but $result is empty.

$result = db_query("SELECT title FROM node WHERE type='foo_type' ORDER BY title ASC");

Please note any D6 and D7 differences if there are any.

joejam
  • 131
  • 1
  • 9