Example Queries

Select Options

select * from my_table;
If you wish to limit the number of rows returned, then do this:
select * from my_table\G
Same as above but change the output format to be more of a record view rather than row
select * from my_table limit 10;
Where the "limit" option comes after where, order by etc. You can specify an offset, with the limit, to help page your way through results.

Select Functions

There are many functions that can be used in the select clause of a query. One example is substr, which takes three parameters as follows: text, start, length
Typically the text will be the name of a column, followed by the character to start at and finally the number of characters required. So with a table of cars select colour from cars where id = 1; returns "Blue"
Following on from this, some examples of the use of substr are:
select colour, substr(colour, 1, 1) from cars where id = 1; - returns "Blue, B"
select colour, substr(colour, 2, 1) from cars where id = 1; - returns "Blue, l"
select colour, substr(colour, 2, 2) from cars where id = 1; - returns "Blue, lu"
select colour, substr(colour, 2) from cars where id = 1; - returns "Blue, lue", leaving the length off gives the rest of the text
select colour, substr(colour, -1, 1) from cars where id = 1; - returns "Blue, e", negative numbers count backwards from the end
select colour, substr(colour, -2, 1) from cars where id = 1; - returns "Blue, u"
There are of course similar ways of getting the same results.