How to learn SQL

Lazarus52980

Senior member
Sep 14, 2010
615
0
71
Since we use a lot of SQL at my employeer, I thought it might be fun to try to learn the basics of how it works and how to write basic SQL scripts.

Could anyone give me any advice on the best way to get started? Any books that work well?

Thank you very much oh great progamers of AT. :)
 

Saint Nick

Lifer
Jan 21, 2005
17,722
6
81
Lazarus, do you have a client (SQL Developer, Toad, SQL*plus) that you can use to submit scripts, and do you know how to submit scripts? Do you know what type of database your applications use?

W3C Schools is a great resources for anyone getting into SQL. I love SQL, and found it very easy to pick up.

If you are on Oracle, you can do lots of fun stuff with:

Code:
select  to_char(sysdate, 'YYYYMMDD')
from dual
Or really selecting anything from dual in order to just play with functions!
 

Lazarus52980

Senior member
Sep 14, 2010
615
0
71
Lazarus, do you have a client (SQL Developer, Toad, SQL*plus) that you can use to submit scripts, and do you know how to submit scripts? Do you know what type of database your applications use?

We use a database program called firebird. (www.firebirdsql.org), and I have program called IBExpert (Which I believe is made by the same people) to submit scripts. Beyond that, I don't yet know the answers to the other questions... Maybe you could tell me? :sneaky:
 

Saint Nick

Lifer
Jan 21, 2005
17,722
6
81
We use a database program called firebird. (www.firebirdsql.org), and I have program called IBExpert (Which I believe is made by the same people) to submit scripts. Beyond that, I don't yet know the answers to the other questions... Maybe you could tell me? :sneaky:
Cool, so your application's back end is built on Firebird. They must bundle a client for you (most RDBMSes do this anyways). Firebird does the same thing that MySQL, SQL Server (Microsoft), and Oracle 10/11 do, just differently. SQL Server and Oracle are enterprise grade solutions.

From there, I would say learn the architecture of the system (maybe check out the Entity Relationship Diagram or ERD). This is beneficial when trying to join different sets of data together. You would need to probably talk to a DBA to see this. Depending on your organization/business rules, your employer may or may not let you see this. I had to sign a few forms to see HR data (due to sensitivity of info with SSNs and what not).

Otherwise, if you want to skip looking at diagrams, and dive into code, you should find a table that stores data you can understand. For example, I primarily work with tables that store work orders and purchase orders, so when I see that data, I know what is being presented. From there, just run

Code:
select * from [tablename]
and you can see everything in there. At that point, you can modify the query to select only specific columns, or specify a WHERE clause so you can filter out (or keep!) certain results.

For example...
Code:
select purchase_order_nbr, purchase_order_rev, purchase_order_desc, purchase_order_creator
from pomaster
where purchase_order_creator = 'SaintNick'

hope that helps :)
 
Last edited: