SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Mar 2005
    0 Post(s)
    0 Thread(s)

    Problems writing a query in MSSQL

    Hi guys, this is my first post here. I'm having a lot of trouble writing a fairly simple(i think) query. Here's the situation.

    I have a database for an online shopping system that uses Modified Preordered Tree Traversal. basically i need to make a query that does the following:

    Select fields named c_left and c_right from a table named categories where the id = a value that will be set by my asp code. For now lets say we need to select c_left and c_right from categories where id=16. then based on the c_left and c_right values i have returned from this i need to select * from categories where c_left > the c_left found from part one of the query and c_right < the c_right from part one.

    Any help on this would be greatly appreciated.

  2. #2
    SitePoint Guru
    Join Date
    Jan 2004
    Uppsala, sverige
    2 Post(s)
    1 Thread(s)
    Select *
    from categories 
    where c_left >
      (select c_left
         from categories
        where id = <aspVariable>)
     and c_right <
    (select c_right
         from categories
        where id = <aspVariable>)


Posting Permissions

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