Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Learning SQL  (Read 1238 times)

ancistrus

  • Bay Watcher
    • View Profile
Learning SQL
« on: June 13, 2014, 03:28:04 pm »

Jobhunting. (Argh) It seems a lot of positions I desire require at least some knowledge of SQL. Since I know nothing about SQL I thought I'd ask here: how do I start with it? I suppose I could just google it, but I trust the advice of people here more than random google results.
Logged

nenjin

  • Bay Watcher
  • Inscrubtable Exhortations of the Soul
    • View Profile
Re: Learning SQL
« Reply #1 on: June 13, 2014, 04:44:49 pm »

Extremely relevant to my life.

I started with my company a little under three years ago.

Coming in, I had a layman's understanding of programming, or structured languages. Something = something.

Today, I can confidently write a query, specifying which data points I care about, what the qualifiers are, joining in other tables to create data sets, apply math logic to my queries (something less than something, sometimes times something), alter thousands of database entries with a simple statement, ect....

I'm not a smart man. Most of what I learned was at the feet of people who have been writing in SQL for years, and Googling SQL help pages.

But it basically comes down to two parts:

1. Your SELECT statement, where you say what datapoints you want
2. Your WHERE statement, where you place qualifiers on the data you want.

Most basic queries are built on this foundation. There's plenty of other more complicated stuff (subqueries, joins, aliasing, query magic), but if you can grok SELECT & WHERE, you can get your foot in the door.

It can help to study the conceptual model of databases too. Go read up on "Relational Databases."

Seriously, you want to know what I started learning SQL and database logic with? http://www.amazon.com/Manga-Guide-Databases-Mana-Takahashi/dp/1593271905

Don't fret. I'm not good at math, logical thinking or complex series of operations, but I managed to understand query writing and mysql to the point I can perform at an entry level position doing it. A crucial part starting out is....just break down a query into individual statements. It's much easier to understand when it's not one long, contiguous line of statements.

This is the webpage I use for my cheatsheet: http://dev.mysql.com/doc/refman/5.5/en/string-functions.html#function_concat-ws

Also it really, REALLY helps to have a good database browser, once you've got the basics down. I'd recommend SQLYOG Community because it's free. It will be of no use to you without a working database, but in teaching yourself how to operate it, you can get ahead of the game. (All SQLYOG essentially does is run queries based on what you're doing in the UI. So for example when you right click and select "Create a new table", SQLYOG is running the query CREATE TABLE <name>; (simplified version of what it's doing) in the background. You could accomplish the same feat just by writing that query in the query window.

Let me know if there's something you would like some help understanding how to do.
« Last Edit: June 13, 2014, 04:55:06 pm by nenjin »
Logged
Cautivo del Milagro seamos, Penitente.
Quote from: Viktor Frankl
When we are no longer able to change a situation, we are challenged to change ourselves.
Quote from: Sindain
Its kinda silly to complain that a friendly NPC isn't a well designed boss fight.
Quote from: Eric Blank
How will I cheese now assholes?
Quote from: MrRoboto75
Always spaghetti, never forghetti

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: Learning SQL
« Reply #2 on: June 13, 2014, 05:10:43 pm »

SQL isn't too hard to learn and is definitely a skill you should pick up(I've used it pretty much everywhere I've worked).  Also every interview I've been a part of we ask programmers if they know it.

I'm not sure of a particular good source of learning it though.  Its worth remembering that each database has a slightly different dialect, so what works perfectly fine for oracle might not work for mysql.  The generals are all pretty much the same though.

It was designed to be somewhat natural-englishy though, so if you come from a programmer background it can be a bit weird to figure out at first.  Try to think of everything as sets instead of logic and it helps a bit.


Seriously, you want to know what I started learning SQL and database logic with? http://www.amazon.com/Manga-Guide-Databases-Mana-Takahashi/dp/1593271905

That looks amazing.  :o  I had no idea such things existed.
« Last Edit: June 13, 2014, 05:42:45 pm by Levi »
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

Jelle

  • Bay Watcher
    • View Profile
Re: Learning SQL
« Reply #3 on: June 14, 2014, 03:17:35 pm »

SQL is fairly simple, shouldn't be hard to learn. W3schools has some good tutorials, sql included.
I can also explain the very basics, I'm quite handy with a database. Would need to know what and if so how much you know about relational databases though.

Also if you're up for it I recommend learning plsql once you've grasped sql. It has some really nifty functionality.
Logged

nenjin

  • Bay Watcher
  • Inscrubtable Exhortations of the Soul
    • View Profile
Re: Learning SQL
« Reply #4 on: June 14, 2014, 04:13:05 pm »

Seriously, you want to know what I started learning SQL and database logic with? http://www.amazon.com/Manga-Guide-Databases-Mana-Takahashi/dp/1593271905

That looks amazing.  :o  I had no idea such things existed.

There's a whole range of Manga How-Tos. They're awesome.
Logged
Cautivo del Milagro seamos, Penitente.
Quote from: Viktor Frankl
When we are no longer able to change a situation, we are challenged to change ourselves.
Quote from: Sindain
Its kinda silly to complain that a friendly NPC isn't a well designed boss fight.
Quote from: Eric Blank
How will I cheese now assholes?
Quote from: MrRoboto75
Always spaghetti, never forghetti

Arni

  • Bay Watcher
  • Soldier
    • View Profile
Re: Learning SQL
« Reply #5 on: June 16, 2014, 06:38:26 am »

I'm a big fan of learning by doing.

I suggest: First you get yourself a database.
A free one like PostgreSQL or MySQL (I prefere Postgre)
Important: SQL is a Standard. How it's exactly implemented depends on the database.
The basics are mostly the same for every system though.

After installing your database start playing with it.
For that we need to get some way to communicate with it. You can allways use the command line, but I'm a lazy bastard an prefere some GUI. For example pgAdmin with comes with the postgre database.
There you can open a query tool which allows you to run your SQL-Statements.

Need an idea what to do?
Create a database (in which you will do the following things)
Create a Table with people (first_name, last_name,age,job) [Look for examples
Insert a few entries
Select your entries
Select all entries with the same job
Select all entries younger than 25 years
et cetera...

That should cover the very rough basics. Next step would be the joins
Logged
Military and Militia. It's horrible

zombat

  • Bay Watcher
    • View Profile
Re: Learning SQL
« Reply #6 on: June 19, 2014, 02:44:37 pm »

Learning SQL in a few easy steps:
1. Read an Online Tutorial on SQL
2. Stare dumbfounded at the screen and say "It surely cant be that simple"
3. Realise it is
4. Enter into a 30k starting salary job pulling raw data from databases and turning it into pretty graphs.
[Optional] 5. Get sick with guilt after noticing you're minted while the poor techies are killing themselves for slightly more than stacking shelves at a super market
Logged

ancistrus

  • Bay Watcher
    • View Profile
Re: Learning SQL
« Reply #7 on: June 19, 2014, 03:50:25 pm »

Learning SQL in a few easy steps:
1. Read an Online Tutorial on SQL
2. Stare dumbfounded at the screen and say "It surely cant be that simple"
3. Realise it is
4. Enter into a 30k starting salary job pulling raw data from databases and turning it into pretty graphs.
[Optional] 5. Get sick with guilt after noticing you're minted while the poor techies are killing themselves for slightly more than stacking shelves at a super market

Not gonna happen, don't live in the US. Still, sounds good.
Logged

nenjin

  • Bay Watcher
  • Inscrubtable Exhortations of the Soul
    • View Profile
Re: Learning SQL
« Reply #8 on: June 19, 2014, 04:30:10 pm »

Quote
[Optional] 5. Get sick with guilt after noticing you're minted while the poor techies are killing themselves for slightly more than stacking shelves at a super market

5a. Work for a company as tech support, and pull data from databases, and make pretty graphs for slightly more than stacking shelves at a super market.
Logged
Cautivo del Milagro seamos, Penitente.
Quote from: Viktor Frankl
When we are no longer able to change a situation, we are challenged to change ourselves.
Quote from: Sindain
Its kinda silly to complain that a friendly NPC isn't a well designed boss fight.
Quote from: Eric Blank
How will I cheese now assholes?
Quote from: MrRoboto75
Always spaghetti, never forghetti