Results 1 to 2 of 2

Thread: T-Sql Query Help

  1. #1
    Join Date
    Apr 2009

    T-Sql Query Help

    I have a problem that is beyond my current knowledge.

    I am trying to create a query similar to the following

    "Select field1, field2, (Select field3 from table1 where field3 = field2) From table2 where field 1 = value"

    I know this won't work because the subquery is done before the main query so It can't compare to a field in the main query. Is there a way to accomplish this. I hope this makes sense, thanks for any help.

  2. #2
    Join Date
    Apr 2009

    Ok, I think I got it

    I was making it harder than it really was, I think I figured it out. I used an inner join.

    SELECT tblContent.ForeignKey AS contentFK, tblContent.Title, tblLinks.LinkURL, tblLinks.LinkParentMenuNone, tblLinks.MenuItemLinked, tblLinks.SortOrder, tblLinks.ForeignKey, tblLinks.Published FROM tblContent INNER JOIN tblLinks ON tblContent.ForeignKey = tblLinks.ForeignKey WHERE (tblLinks.LinkParentMenuNone = 'parent') AND (tblLinks.Published = 1)ORDER BY tblLinks.MenuItemLinked, tblLinks.SortOrder

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts