Results 1 to 2 of 2

Thread: How do I do a query that uses all users?

  1. #1
    Nathan Czuba Guest

    How do I do a query that uses all users?






    Hello,

    I am doing a website that incorporates SQL and one of the things is which user to query for. In this part, I would like to put
    the variable 'AllUsers' which consists of all the users, do you have any suggestions on how this can be done, here is what I
    have without a query for 'AllUsers' in HTML:

    <SELECT NAME=&#34;targetUserID&#34;>
    <OPTION VALUE=&#34;AllUsers&#34;>All Users</OPTION>
    <!-- =queryString &#34;select distinct rtrim(userID) from
    Track..cUsers order by userID&#34; -->
    <!-- ?{sqlBlock $queryString crux 2000 0 -1 errorString tmpuserID -->
    <OPTION VALUE= &#34;<!-- $ $tmpuserID -->&#34;
    <!-- ({ $tmpuserID == $targetUserID --> SELECTED<!-- (} -->>
    <!-- $ $tmpuserID --></OPTION>
    <!-- ?}sqlBlock -->
    </SELECT>

    Here is what I thought would work, but it didn&#39;t:

    <SELECT NAME=&#34;targetUserID&#34;>
    <!-- =queryString &#34;declare @AllUsers varchar(16) select @AllUsers = userID from Track..cUsers&#34; -->
    <!-- ?{sqlBlock $queryString crux 2000 0 -1 errorString AllUsers -->
    <OPTION VALUE=&#34;AllUsers&#34;>All Users</OPTION>
    <!-- ?}sqlBlock -->

    <!-- =queryString &#34;select distinct rtrim(userID) from
    Track..cUsers order by userID&#34; -->
    <!-- ?{sqlBlock $queryString crux 2000 0 -1 errorString tmpuserID -->
    <OPTION VALUE= &#34;<!-- $ $tmpuserID -->&#34;
    <!-- ({ $tmpuserID == $targetUserID --> SELECTED<!-- (} -->>
    <!-- $ $tmpuserID --></OPTION>
    <!-- ?}sqlBlock -->
    </SELECT>



    In case you dont like how that looks here is what I thought would work just in SQL:

    declare @AllUsers varchar(16)
    select @AllUsers = userID
    from Track..cUsers

    I also tried to do it with my query for the final information, but that didnt work either it went something like this:

    select DATEDIFF( hour, startTime, stopTime), cSlice.projectID &#34; +
    from Track..cSlice, Track..cProjects
    where &#39;&#34; + $targetUserID + &#34;&#39; = &#39;AllUsers&#39;
    and clientID = &#39;&#34; + $targetClientID + &#34;&#39;
    and state = &#39;Stopped&#39;
    and typeID = &#39;Billable&#39;
    and cSlice.projectID = cProjects.projectID
    and startTime like &#39;&#34; + $targetMonth + &#34;%&#39;
    or userID = &#39;&#34; + $targetUserID + &#34;&#39;
    and clientID = &#39;&#34; + $targetClientID + &#34;&#39;
    and state = &#39;Stopped&#39;
    and typeID = &#39;Billable&#39;
    and cSlice.projectID = cProjects.projectID
    and startTime like &#39;&#34; + $targetMonth + &#34;%&#39;
    order by cSlice.projectID

    Any help would be greatly appreciated, Thank you for your time.
    Nathan Czuba

  2. #2
    Nathan Guest

    How do I do a query that uses all users? (reply)

    nm, i figured it out, thanks anyways


    ------------
    Nathan Czuba at 7/5/00 11:38:12 AM






    Hello,

    I am doing a website that incorporates SQL and one of the things is which user to query for. In this part, I would like to put
    the variable &#39;AllUsers&#39; which consists of all the users, do you have any suggestions on how this can be done, here is what I
    have without a query for &#39;AllUsers&#39; in HTML:

    <SELECT NAME=&#34;targetUserID&#34;>
    <OPTION VALUE=&#34;AllUsers&#34;>All Users</OPTION>
    <!-- =queryString &#34;select distinct rtrim(userID) from
    Track..cUsers order by userID&#34; -->
    <!-- ?{sqlBlock $queryString crux 2000 0 -1 errorString tmpuserID -->
    <OPTION VALUE= &#34;<!-- $ $tmpuserID -->&#34;
    <!-- ({ $tmpuserID == $targetUserID --> SELECTED<!-- (} -->>
    <!-- $ $tmpuserID --></OPTION>
    <!-- ?}sqlBlock -->
    </SELECT>

    Here is what I thought would work, but it didn&#39;t:

    <SELECT NAME=&#34;targetUserID&#34;>
    <!-- =queryString &#34;declare @AllUsers varchar(16) select @AllUsers = userID from Track..cUsers&#34; -->
    <!-- ?{sqlBlock $queryString crux 2000 0 -1 errorString AllUsers -->
    <OPTION VALUE=&#34;AllUsers&#34;>All Users</OPTION>
    <!-- ?}sqlBlock -->

    <!-- =queryString &#34;select distinct rtrim(userID) from
    Track..cUsers order by userID&#34; -->
    <!-- ?{sqlBlock $queryString crux 2000 0 -1 errorString tmpuserID -->
    <OPTION VALUE= &#34;<!-- $ $tmpuserID -->&#34;
    <!-- ({ $tmpuserID == $targetUserID --> SELECTED<!-- (} -->>
    <!-- $ $tmpuserID --></OPTION>
    <!-- ?}sqlBlock -->
    </SELECT>



    In case you dont like how that looks here is what I thought would work just in SQL:

    declare @AllUsers varchar(16)
    select @AllUsers = userID
    from Track..cUsers

    I also tried to do it with my query for the final information, but that didnt work either it went something like this:

    select DATEDIFF( hour, startTime, stopTime), cSlice.projectID &#34; +
    from Track..cSlice, Track..cProjects
    where &#39;&#34; + $targetUserID + &#34;&#39; = &#39;AllUsers&#39;
    and clientID = &#39;&#34; + $targetClientID + &#34;&#39;
    and state = &#39;Stopped&#39;
    and typeID = &#39;Billable&#39;
    and cSlice.projectID = cProjects.projectID
    and startTime like &#39;&#34; + $targetMonth + &#34;%&#39;
    or userID = &#39;&#34; + $targetUserID + &#34;&#39;
    and clientID = &#39;&#34; + $targetClientID + &#34;&#39;
    and state = &#39;Stopped&#39;
    and typeID = &#39;Billable&#39;
    and cSlice.projectID = cProjects.projectID
    and startTime like &#39;&#34; + $targetMonth + &#34;%&#39;
    order by cSlice.projectID

    Any help would be greatly appreciated, Thank you for your time.
    Nathan Czuba

Posting Permissions

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