I have had this thing in my head from quite some time about learning SQL and thinking that it was going to be impossible for me. Last evenings Uni class was the last one of the semester so the subject was slightly off topic but we looked at logging into phpMyAdmin which is scary on its own.

phpMyAdmin is basically raw access to the underlying databases on the web server. You are met with a not so neat but semi graphical interface that used to scare the hell out of me. After being show a few basics and where to type in the SQL come and how to get it to use certain tables the queries weren’t that bad and the basic logic was very understandable. We used MySQL so the point was made that there are different version with different little quirks to keep an eye out for e.g. MySQL is case sensitive whereas Microsoft Server SQL is case nonsensitive.

Anyway we looked at 3 basic commands, and here they are:

*First off imagine you have a database called People that has a table within it called Details, that table contains columns of information for Name, Age, Address, Telephone No. etc.

To list all the information from that table you can use the following SQL query:

USE People;
SELECT *
FROM Details;

And that’s it. You tell the query which database name to USE, what to SELECT - everything in this case with the wildcard (*) and which table in the database to get the information FROM.

To select limited fields like Name and Telephone No. you would change the query to read:

USE People;
SELECT Details.Name, Details.TelephoneNo,
FROM Details;

The only part that has changed is the SELECT function where you specify the table.fieldname that you want included in the report.

These reports are run in phpMyAdmin so my next step is to expand on this and find out how to display the results on a web page. For this I am going to look at the Ruby on Rails framework over the Summer. It was a real fast run through and knowing a little about databases really paid off as I picked up most of what was said in the session.

I will add more SQL posts as I learn how to do more things with it.

Has this helped anyone?