This macro will allow you to execute a select statement on any predefined datasource. Macro Overview: Syntax: #getSQLResults("select * from table") Arguments: dbConnection Optional: By default the macro will execute your query against the dotCMS database unless you set a dbConnection. dbStartRow Optional: If you set dbStartRow your results will start at the given row. The dbStartRow is zero based meaning that the first row is row 0. dbMaxRowOptional: If you set dbMaxRow your results will be limited to your maxRows. When possible your should do this with a limit in your query. Optional Parameters: Usage: Use this macro if you want to pull data from a database and display the results within some piece of content. If the SQL throws an error it will store the error in a variable named SQLError. See the example below for instructions on how to use this. It is only optional that you check for the error but it is recommended that you do so that your sql won"t fail silently. Examples: Example 1: A simple example using the required fields #set ($dbConnection = "jdbc/test1") #set ($dbStartRow = 1) #set ($dbMaxRow = 4) #getSQLResults("select * from test order by id") #if($UtilMethods.isSet($SQLError)) Custom SQL message - I Failed #else #foreach($r in $results) $r.id #end #end Example 2: Display all HTML Pages names on your site #getSQLResults("select title from htmlpage") #foreach($myvar in $results) $myvar.get("title") #end 2