SQL

Reset MySQL Root Password

Reset MySQL Root Password

If you have mysql- or root user shell access to the linux host where your mysql is running, you can reset the password like this:

Read more…

Column count in SQL

Column count in SQL

At rare occasions you might need to know the number of columns in a database table. This isn’t necessarily as easy as counting rows.

Read more…

SQL case sensitive queries

SQL case sensitive queries

MSSQL will not search in a case sensitive way by default. Below are two popular ways to solve it.

Read more…

MS Access Connection Strings

MS Access Connection Strings

There are two common connection string types that can be used to connect to an MS Access database.

Read more…

PHP MS Access connection with COM

PHP MS Access connection with COM

While doing some work where I had to make a graph module in PHP based on information from an access database, I had to know how to connect to it without a database source name (DSN). I looked up PHP COM (ADODB) which worked great.

Read more…

SQL random rows

SQL random rows

To retrieve random rows in SQL you can consider the following SQL queries. It’s worth to mention that this option suit small needs best, e.g. 50-100 records/rows. This is in regards to performance and can be tested by yourself. Personally I use it for small boxes where I only want a few rows to show.

Read more…

Quick note on INNER JOIN

Quick note on INNER JOIN

Consider the tables, and how they are related in a chain-like way.

Let’s say that I want to list name, worktype and country. I could use code with nested for loops which is labor heavy, totally unnecessary and might even create notable delay, or I could just use JOIN.

There are three types of join, I use 2 of them quite often.

Read more…

Quick note on CROSS JOIN

Quick note on CROSS JOIN

This is one of those things that’s nice to know when starting out as a web developer. Instead of writing 2 queries to first get 1 value from 1 table, just to be able to use it in another query against the same table again, you can instead use a subquery as a table in your main query.

Read more…