1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

MySQL subqueries help!

Discussion in 'Scripting & Programming' started by Alex Wright, Jan 9, 2009.

  1. Alex Wright

    Alex Wright Megabyte Poster

    501
    9
    57
    Does anyone know of any good online resources where I can practice them? They're the one thing I'm struggling to get my head around at the moment.

    All help greatly appeciated.

    Alex
     
    Certifications: 70-680 Configuring Windows 7
    WIP: 70-642
  2. zebulebu

    zebulebu Terabyte Poster

    3,748
    330
    187
    Have you tried the MySQL documentation? I don't wanna go all RTFM on you, but it gives a decent explanation of what a subquery is: MySQL Subqueries

    Why are you struggling with them? What is it you don't understand?
     
    Certifications: A few
    WIP: None - f*** 'em
  3. Alex Wright

    Alex Wright Megabyte Poster

    501
    9
    57
    To be honest Zeb, it's not so much I don't understand their uses, I'm just struggling with the examples in the book that I'm working from, because the examples are based on a database that you don't create from scratch, you just download the .sql file from O'Reily's website.

    I understand what noncorrelated and correlated subqueries are, but it's when I have to use them in unison with table joins, conditional logic, etc etc that I struggle. I think the only way to improve is to PRACTICE, PRACTICE, PRACTICE. Trouble is, there's no decent tutorials that I can find online.
     
    Certifications: 70-680 Configuring Windows 7
    WIP: 70-642
  4. greenbrucelee
    Highly Decorated Member Award

    greenbrucelee Zettabyte Poster

    14,283
    254
    329
    I used this at uni to help me www.w3schools.com/sql/default.asp

    It's not available at the minute, I think their server is down but it has some useful easy to understand info.
     
    Certifications: A+, N+, MCDST, Security+, 70-270
    WIP: 70-620 or 70-680?
  5. Alex Wright

    Alex Wright Megabyte Poster

    501
    9
    57
    GBL - thanks mate. I just find W3C's tutorial too basic. I've been through it once already and didn't find it much help! I think I'll just have to purchase an advanced SQL book. Can you recommend one?
     
    Certifications: 70-680 Configuring Windows 7
    WIP: 70-642
  6. hbroomhall

    hbroomhall Petabyte Poster Gold Member

    6,623
    115
    224
    For general SQL work I always recommend:
    Joe Celko's SQL for Smarties (3rd Edition, Morgan-Kaufmann, 2005) ISBN 978-0-12-369379-2

    However - MySQL tends to not follow standards very much, and you may find that a book on the exact version you are using to be more helpful.

    Harry.
     
    Certifications: ECDL A+ Network+ i-Net+
    WIP: Server+
  7. Alex Wright

    Alex Wright Megabyte Poster

    501
    9
    57
    Hi Harry,

    I'll have a look at the TOC and report back.

    One question: are there practice question at the end of the chapters. I'm one of these people that needs to put what I've learnt into practice. If I don't, I tend to forget what I've learnt the next day!
     
    Certifications: 70-680 Configuring Windows 7
    WIP: 70-642
  8. hbroomhall

    hbroomhall Petabyte Poster Gold Member

    6,623
    115
    224
    My copy is at home, and I don't remember at the moment. I'll look this evening and report.

    Harry.
     
    Certifications: ECDL A+ Network+ i-Net+
    WIP: Server+
  9. Alex Wright

    Alex Wright Megabyte Poster

    501
    9
    57
    Excellent - thanks!
     
    Certifications: 70-680 Configuring Windows 7
    WIP: 70-642
  10. hbroomhall

    hbroomhall Petabyte Poster Gold Member

    6,623
    115
    224
    Having now looked at the book - sorry - there are no questions at the end of each chapter.

    However - I found there were sufficient 'real world' examples in the text for it to be invaluable to me.

    My major gain from it was to find a way of doing 'pivot tables' (aka crosstabs) in SQL - which previously I hadn't thought possible.

    Harry.
     
    Certifications: ECDL A+ Network+ i-Net+
    WIP: Server+
  11. Alex Wright

    Alex Wright Megabyte Poster

    501
    9
    57

    Thanks Harry.

    I read some reviews on the book yesterday and several of the contributors warned that this is by no means an introductroy SQL book. As somebody that's fairly new to the language, in your opinion, do you still think it's worth me purchasing a copy?
     
    Certifications: 70-680 Configuring Windows 7
    WIP: 70-642
  12. hbroomhall

    hbroomhall Petabyte Poster Gold Member

    6,623
    115
    224
    I didn't realize you wanted an introductory book. You asked about subqueries, and to me that isn't introductory! :biggrin

    I'd agree that the Celko book isn't for beginners - for that try the Dummies book!

    But for anybody who can construct straightforward queries, with the odd join thrown in, and can tell the difference between an inner join and an outer join, then I'd say the Celko book is a must.

    Harry.
     
    Certifications: ECDL A+ Network+ i-Net+
    WIP: Server+
  13. Alex Wright

    Alex Wright Megabyte Poster

    501
    9
    57
    The "introductory" book I currently have on SQL covers some advanced concepts. And as such, I'm already able to construct queries which include: joins, subqueries, conditional logic, etc.

    Just wanted to double check that wouldn't get lost during the first couple of chapters on the Celko book. Don't want to run before I can walk so to speak!

    Alex
     
    Certifications: 70-680 Configuring Windows 7
    WIP: 70-642

Share This Page

Loading...