TSQL Query Advice

  • Hello all,

    I am relatively new to tsql and have come across an issue I do not know how to solve. I have a master table and associated (by FK) child table like so:

    masterTable: mID, mName, mType.

    childTable: cID, cName, mID.

    I need a query that will get all records from the masterTable and set some variable(?) or attribute if more than one related record (mID) exists in the childTable.

    Should I be using correlated subqueries etc?

    Any advice would bew greatly appreciated.

    Adam.

  • Please post table definitions, sample data and desired output. Read this to see the best way to post this to get quick responses.

    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Sounds like you just want a JOIN. Read the article Gail suggested and post the code you've tried so far.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 3 posts - 1 through 3 (of 3 total)

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