Category Archives: database

SQL: Selecting Specifying Multiple Field Values

Here are 3 different ways to perform a DB select when you want to specify two or more values for a field.
1. Use th OR operator
PLAIN TEXT
SQL:

SELECT * FROM people

WHERE (first_name = 'pete'

OR first_name = 'paul');

2. Use a Regular Expression
PLAIN TEXT
SQL:

SELECT * FROM people

WHERE first_name ~'^pete|paul$';

3. Use an array
PLAIN TEXT
SQL:

SELECT * FROM people

WHERE [...]

MySQL tips: Grants and Changing Passwords

I was doing some work administering MySQL databases earlier in the week. I haven’t done much with MySQL in over half a year since we use Postgres as the backend for phuser.com, needless to say I’d forgotten a lot of the commands! Here are a few MySQL tips which I’m putting up here for my [...]