Results 1 to 3 of 3

Thread: Select statements

  1. #1
    Join Date
    Jan 2008
    Posts
    55
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Select statements

    Couple of things. I'm using the following:

    <%
    dim adoVu
    dim strUser
    strUser=Session("UserID")
    strVu = "SELECT * FROM FavVenues WHERE UsrID=" & strUser
    set adoVu = adoCn.Execute(strVu)
    %>
    <% Do While Not adoVu.EOF%>
    VenueID=<%=adoVu("VenID")%>
    <%adoVu.MoveNext
    Loop%>


    to give me an output (bit above in Italics) of VenueID=6

    Which I want to be included here:

    <%
    dim adoVn
    strVn = "SELECT * FROM Venues Where VenueID=6 OR VenueAddedBy=" & strUser
    set adoVn = adoCn.Execute(strVn)
    %>

    The above works using VenueID=6 as a fixed variable.

    Couple of issues how do I include the first set of code in the above SELECT statement and the other thing is I actually want VenueAddedBy=" & strUser first with OR VenueID=6 after - basically you can have more that one venue so it could be OR VenueID=6 OR VenueID=9 etc so I intend on adding OR in the loop. At the moment when I try and do it the other way round, or do a ORDER BY statement after "& strUser I get errors.

  2. #2
    Join Date
    Feb 2004
    Posts
    4,903
    Thanks
    2
    Thanked 134 Times in 113 Posts

    Default

    Is this what you want (not checked for SQL Injection):

    Code:
    <%
    Dim adoVn
    Dim strUser, strVn
    
    strUser = Session("UserID")
    
    strVn = "SELECT * FROM Venues WHERE VenueID IN (SELECT VenID FROM FavVenues WHERE UsrID = " & strUser & ") OR VenueAddedBy = " & strUser & " ORDER BY VenueID"
    
    Set adoVn = adoCn.Execute(strVn)
    %>
    Warren Ashcroft
    Red Fox UK Limited - Pioneers in Internet Technology
    http://www.redfoxuk.com
    w.ashcroft [at] redfoxuk.com

    NOTE: Forum Private Messaging should not be used to contact staff with support queries.

  3. #3
    Join Date
    Jan 2008
    Posts
    55
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    That's exactly what I wanted. Thanks.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Select PHP errors
    By davindersangha in forum PHP
    Replies: 1
    Last Post: 18th May 2009, 04:07 PM
  2. Replies: 0
    Last Post: 26th March 2007, 04:04 PM
  3. Guest ( ' UNION SELECT e )
    By Service Engineer in forum General Technical Support
    Replies: 1
    Last Post: 15th July 2006, 01:53 AM
  4. Select All from Jump Menu
    By s80wkr in forum ASP (VBScript)
    Replies: 2
    Last Post: 28th February 2006, 03:26 PM

Bookmarks

Posting Permissions

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