Help:Inline queries/Introduction to "hash"ask

Subpages of the main Help page: * 1 /Introduction to "hash"ask * 2 /The "hash"show parser function
 * 3 /Standard parameters for inline queries
 * 3.1 /Result limits and links to further results
 * 3.2 /Introduction and default text
 * 3.3 /Sorting results
 * 3.4 /Configuring labels or table headers
 * 3.5 /Changing the first result column
 * 4 /Result formats
 * 5 /Exporting query results: RSS, etc.
 * 6 /Using templates for custom formatting

The basic way of writing an inline query is to use the parser function #ask. The query string (See selecting pages for syntax) and any printout statements are directly given as parameter, like in the following example:

Here we query for all cities located in Germany, and two additional printout statements are used (a simple one and one with some extra settings). This displays the following result on a page:

It is common to put the query as the first parameter behind #ask:. All other parameters are separated by |, just like for other parser functions. The exact formatting of the inline query is not essential, but it is good to use line breaks to make it more readable to other editors. As with all templates, one line per parameter, starting with the | is most accepted in practice.

Note that all the arguments to the #ask: function are ignored by the page parsing, hence the above example does not add a category or a «located in» property annotation to this page. A few more things to note are:
 * The pipe '|' symbol is used to separate the conditions from the property to display.
 * The conditions for display are a single argument to the #ask function, so there are no '|' symbols between them.
 * White space and line breaks can be used within the #ask function, SMW is fairly flexible there.
 * The format of the results display changes when you request display of additional properties. SMW picks an appropriate default format for query results, but you also have detailed control of the appearance of query results.

Knowing the basics of query string and printout statements therefore is enough to write many kinds of queries. But there are many cases where the standard table output of a query may not be the best choice, or where further settings are desired (like the maximum number of results that should be displayed). For this purpose, inline queries have a number of other possible parameters that one can use to control their appearance in detail. The general syntax for #ask</tt> therefore is the following:

Most of this page explains the various arguments one may use in inline queries.

Prior to Semantic MediaWiki 1.0 there was a different syntax for inline queries using an  </tt> tag, which is still enabled on some wikis. Please see the old documentation page for details on this feature. It is strongly recommended to use only the new syntax now.