Returning data from Multiple tables.

  • hi,

    I have 3 tabled mt_wpr, and mt_tags, and mt_tags_rel. I need to retrieve data from mt_wpr and from mt_tags.

    mt_tags_rel holds the relation between mt_wpr and mt_tags.

    i have written the following query.

    SELECT mt_wpr.ID, mt_wpr.Title, mt_wpr.Description, CONVERT(varchar, mt_wpr.UploadDate, 107) AS Date, mt_wpr.cid, mt_tags.tag FROM mt_wpr, mt_tags INNER JOIN mt_tags_rel ON mt_tags.ID = mt_tags_rel.tagID WHERE mt_tags_rel.type=1 AND mt_tags_rel.itemId=mt_wpr.ID AND mt_wpr.UserID='db50748b-c86e-42f7-aa31-3d48debb1bfe' GROUP BY mt_tags.tag, mt_tags_rel.tagId, mt_wpr.ID, mt_wpr.Title, mt_wpr.Description, mt_wpr.UploadDate, mt_wpr.cid

    This query gives me the results that i need with only on exception.

    Each row in mt_wpr has multiple rows in mt_tags and i my query shows me only the last row from mt_tags. i need to be able to return all the queries separated by a ','

    Please advise. If this is possible or not.

    Thanks

    johnfern

    John P Fernandes
    Enterprise Premier Support | Networking | Microsoft India GTSC

  • John Peter Fernandes (7/18/2010)


    ...

    Please advise. If this is possible or not.

    ...

    It is possible.

    For more details please follow the advice from the link in my signature.

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

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

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