You can use data defined properties for this. Use the style tab on the layer properties and click the expression button to the right of the color.
In there you can use the function color_rgba( red, green, blue, alpha ) to create the color. All values need to be between 0 and 255.
Example:
color_rgba( 255, 0, 0, ( 1 - "transparency" ) * 255 )
This will ...

Double quotes indicate that the string represents the name of an attribute while a single quote is a literal string.
So in your first case you get NULL because you don't have an attribute called something.

Your observation is correct, The Query Builder does not use the same syntax as the rest of QGIS.
Throughout QGIS, the syntax is based on QGIS Expressions a customized SQL dialect. This is portable between almost all parts of QGIS where you can enter a filter, calculate a value... This syntax is parsed and evaluated directly in QGIS (and parts of it may be ...

As a follow up to Matthias' answer, in QGIS >= 2.12 you can use a data defined fill color with the expression:
set_color_part(@value, 'alpha', ( 1 - "transparency" ) * 255 )
What this expression does is takes the original polygon color (@value) , and replaces the alpha channel (opacity) with the value calculated from the field). This means you can set ...

This can be done using the Processing Graphical Modeler to set up a custom chain. Here's a pic:
From left to right we have three inputs - the tree layer (a Vector Layer Input Object), the buffer size (a Numeric Input) and the tree height (a String Input). The tree layer is then selected by its height attribute. The selected trees are then buffered by the ...

Underdark has composed some nice examples for labeling expressions:
Easier Conditional Labels in QGIS
Here are some helpful links for querying:
Query Attributes
Working with Attribute Table - Basic Queries
If you are interested in coding then you can start with this resource:
pyQGIS Developer Cookbook

Here is the answer directly from QGIS help:
column name "column name" → Value of the field column name, take care
to not be confused with simple quote, see below
'string' → a string value, take care to not be confused with double
quote, see above

Try this if you want to Select by Expression
GetUtmZone() = '40N'
If you just need to get the return value from the function you can just do
GetUtmZone()
The $ prefix used to be used for functions that took no arguments however that is no longer used in later versions, the version in the tutorial is a older QGIS version that still supported that format.

Can it be done. Of couse with QGIS the answer is normally yes.
Lets take our vector layer with some normal labels and symbols:
Now add a data defined color for the buffer:
Click on Edit and select the function editor.
Click new file and give it a name (called mine colorfuncs)
Paste the following code
from qgis.core import *
from qgis.gui import *
@...

Try with concat('http://www.example.com/img/',"filename",'.jpg'), replace the .jpg with the appropriate extension if all of your images are the same type.
Or concat('http://www.sylve.ch/docs/',"filename") if the extension .jpg or else is included in your name's file.

So the way QGIS handles NULL when you join strings is that it will convert the result to NULL if any part is NULL (yes I know it's on going debate on if it should or not)
Here is how you handle that using the concat function:
concat( "genus_species", '\n', "english_species", '\n', to_string("planted_year")
The concat function will convert NULL to empty ...

You can use the floor function in your expression, like this:
floor($id /24) IN (1,3,5,7,9,11,13,15,17,19,21)
On a sample grid I've obtained this result with my own numbers (my grid has 13 columns per row):
I've used: floor($id/13) IN (1,3,5,7,9)
So, in general:
floor($id / number_of_columns) IN (1, 3, 5, ..., 2*number_of_rows_to_be_selected - 1)
To ...

You only need to include CASE at the beginning and END at the end of your expression. So it should read:
CASE
WHEN "PROP_VALUE" IS 50 THEN '50'
WHEN "PROP_VALUE" IS 100 THEN '100'
...
END
As @Midavalo mentioned, you could also use the modulo operator:
CASE WHEN "PROP_VALUE" % 50 = 0 THEN "PROP_VALUE" END

If there is only need to select 'all permian lithologies' and no other conditions - you can use syntax like this:
"GEOLHIST" LIKE '%Permian%'
This should select all occurencess of 'Permian' word. This will not work with 'permian' probably. But you can change to '%ermian' thought.

It is my understanding you cannot directly perform spatial queries in the Defintion Query tab. However because ESRI offers a calculate geometry option for common shapefile geometry calculations and automatically calculates area for feature classes, you can do a psuedo spatial query on a field containing the value of area for each polygon. For shapefiles the ...

As starting point for studying I would use the QGIS Cookbook. For further reading with additional examples look at the books Joseph suggests in his answer.
As for your specific problem I would suggest string substitution like
it = vl.getFeatures( QgsFeatureRequest().setFilterExpression ( u'"field_name" = {0}'.format(values[j])) )

Unicode has some superscript and subscript characters in it as described on Wikipedia
Here are two custom functions that can be entered in the QGIS Python Function Editor that superscript or subscript the digits in strings passed to them:
Superscript
@qgsfunction(args='auto', group='Custom')
def supscr_num(inputText, feature, parent):
""" Converts any ...

Please follow the python syntax-Just check if hike is in the Name. Below should work
def FindLabel ([Name]):
if 'hike' in [Name]:
return [Name]
But if you need to label only Name does not contain hike use below-
def FindLabel ([Name]):
if 'hike' not in [Name]:
return [Name]
'LIKE' is an SQL operator that may be used with wildcards ...

A value in one (or both) of your fields is a number, and python is trying to add it due to the + symbol, or alternatively it could be a value that can't be handled in its current form. Either way you'll need to tell python that it's a string. It is currently trying to use the value as unicode and it needs a string.
Using the Python Parser you need to use:
...

The easiest way is to modify the expression used for the label to be:
replace( "NAME" , 'District', '')
Or if you are using BoundaryLine then I recommend
regexp_replace( "NAME" , 'District.*$', '')
to deal with districts like 'Allerdale District (B)'.
Infact for completeness I use:
wordwrap( replace(
regexp_replace( "NAME" , 'District.*$|...

You should use the layers Metadata for it. In the Layers properties, fill in Attribution - Title string like shown below (you may use the Url too, as well):
Then insert the following expression into your label item (note the output preview in the screenshot and the arguments description of the layer_properties function on the right, you may access layer ...

Label expressions are similar to field calculator: you don't need to use a for loop as the expression is already applied to every feature. Also, you'll get an error with your code as per the help:
Field values are automatically cast to text strings. Therefore, if you
wish to use a numeric value in an arithmetic operation, or when making
a comparison, ...