Don't know the answer, can't form the question...and, besides, I'm a chicken (wearing a hat)

  • Hi. Sorry in advance for the rather long post.

    The database administrator who worked for me left and I am filling in the best I can.

    I'd love to learn how to do all the magic you all do on the programming side, but (hat's off to you), but I am both pressed for time and a chicken (even if I don't have a hat any more).

    So...after you've fished the cheese (to go with my whine)...

    I'd very much appreciate any recommendations for a good, FREE SQL site (did I mention that I'm cheap) for "advanced" querying that stops short of scripts, stored procedures and other programming that I can look at until I can get up to speed ? I've tried a few, but not much luck.

    Thank you all

  • Which sites did you try that you were disappointed with?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Last time I was looking for a specific topic, I came across this nice site.

    The site is called "SQL Server 2000 Survival Guide".

    http://www.akadia.com/services/sqlsrv_programming.html

    Most of the topics are still the same in SQL 2005.

    Enjoy your reading,

    Peter

  • http://www.sqlservercentral.com/Forums is most probably the best site that I have ever encountered which offers darn good advice.

    Just shoot with your question, and you will have a relatively good answer in a reasonable amount of time.

    Good luck, and welcome on board

    ~PD

    ps> Before posting anything, please access Jeff's link on some good forum manners

  • HI there,

    I agree, SSC is one of the best sites for advice and learning that I have come across 🙂

    Don't be scared fail be excited to learn 😉

    thanks

    Chris

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • As others have said, this is a great site for asking questions and getting articles.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Keep posting here, and we'll try to help.

    Honestly, I'd recommend you beg for some $$ to pick up one SQL 2005 book, any of the admin books (check half.com) and read through it. It will help guide you and we'll be happy to help you understand.

  • Is there a way to take a set of records from one table in a database and compare them to a set of records in a second table and return the results without hardwiring the desired results set into my query?

    For example

    Table 1 - Guys

    GUYCHAR

    MarkTall

    MarkDark

    MarkHandsome

    JoeTall

    JoeBlond

    JoeHandsome

    Table 2 –Women

    WOMANDESIRED

    JudyTall

    JudyDark

    JudyHandsome

    AmyTall

    AmyHandsome

    Despite the obvious shallowness of my query, I want the results to be:

    WOMANGUY

    JudyMark

    AmyMark

    AmyJoe

  • Hey,

    Yes you can, but it will return slightly more than what you are bargaining on

    select

    W.WOMAN, G.GUY

    from Guys as G

    inner join Women as W

    on G.Desired = W.Desired

    This will return any matches based on the desired field

    WOMAN GUY Fields that would match

    Judy Mark (Tall/Dark/Handsome)

    Judy Joe (Tall/Handsome)

    Amy Mark (Tall/Handsome)

    Amy Joe (Tall/Handsome)

    Hope this makes sense

    ~PD

    ps> I agree with Steve, maybe forking out a few pennies on a beginners TSQL manual will assist you in the longer term, there normally is some great examples that you could follow

  • I think that this will do it:

    [font="Courier New"]SELECT DISTINCT

      w.WOMAN,

      g.GUY

    FROM Guys g

      INNER JOIN Women w ON (w.DESIRED = g.CHAR) --has at least one match

    --Need more conditions since the above is too loose

    -- so make sure that all of this woman's desires

    -- are matched by this guy, or exclude him

    WHERE NOT EXISTS( SELECT *

       FROM Women w2

       WHERE w2.WOMAN = w.WOMAN       --same woman as the outer query

        AND NOT EXISTS( SELECT *

           FROM Guys g2

           WHERE g2.GUY = g.GUY       --and same guy as outer query

            AND w2.DESIRED = g2.CHAR   --but some desire is not matched

           )

       )

    [/font]

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • OK, thanks, makes sense...now suppose I throw in another curveball

    Table 1 - Guys

    GUY CHAR

    Mark Tall

    Mark Dark

    Mark Handsome

    Mark Rich

    Joe Tall

    Joe Blond

    Joe Handsome

    Table 2 –Women

    WOMAN DESIRED

    Judy Tall

    Judy Dark

    Judy Handsome

    Amy Tall

    Amy Handsome

    i.e. my list of characteristics on the "GUYs" side includes items that the WOMAN doesn't care about (Judy want a man who is tall darak and handsome, but doesn't care if he is rich or not)? Won't the above query exclude him?

  • This might work for you

    SELECT DISTINCT WM.Woman, GY.Guy

    FROM Woman WM

    INNER JOIN Guy GY ON GY.Char=WM.Desired

    WHERE (SELECT COUNT(1)

    FROM Woman WMM

    WHERE WMM.Woman=WM.Woman)

    =

    (SELECT COUNT(1)

    FROM Woman WMM

    INNER JOIN Guy GYY ON GYY.Char=WMM.Desired

    WHERE WMM.Woman=WM.Woman AND GYY.Guy=GY.Guy)

    *edit* this may not work if you have any duplicate rows

  • mark-o (6/2/2008)


    i.e. my list of characteristics on the "GUYs" side includes items that the WOMAN doesn't care about (Judy want a man who is tall darak and handsome, but doesn't care if he is rich or not)? Won't the above query exclude him?

    My query already assumes that. It only excludes men who do not match every desire of a woman. Extra CHARs have no effect.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • rbarryyoung (6/2/2008)


    My query already assumes that. It only excludes men who do not match every desire of a woman. Extra CHARs have no effect.

    Save yourself some time....we ALL know that the answer to that query will ALWAYS be Null.....:P

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Yes, I did set myself up for it...

Viewing 15 posts - 1 through 15 (of 19 total)

You must be logged in to reply to this topic. Login to reply