SQL Question

Results 1 to 3 of 3

Thread: SQL Question

  1. #1
    Join Date
    Dec 1969

    Default SQL Question

    Hi all;<BR><BR>I am trying to generate and SQL statement to get transactions for a given user. I want to get only transactions for one user and if they are a type that start with Payment or are Void.<BR><BR>The SQL statement I have below does not work. It gets the right transactions for the right user. However, it gets the transaction types Void for all users. Make sense?<BR><BR>rsTransaction.Open "SELECT * FROM Transactions WHERE UserName = &#039" & strUserName & "&#039 AND Type LIKE &#039Payment%&#039 OR Type = &#039Void&#039", objCustomerConn, adOpenDynamic<BR><BR>How do I change this SQL statement so that I don&#039t get data on Voided transactions for users that didn&#039t have transactions voided?

  2. #2
    Join Date
    Dec 1969

    Default RE: SQL Question

    try grouping you AND clause:<BR><BR>SELECT...FROM....WHERE UserName = &#039" & strUserName & "&#039 AND (Type LIKE &#039Payment%&#039 OR Type = &#039Void&#039)", objCustomerConn, adOpenDynamic<BR><BR>I am just taking a stab at it. Hope this helps.

  3. #3
    Join Date
    Dec 1969
    Los Angeles, CA

    Default Am i right???

    you are trying to select data where the transaction is void OR payment.<BR><BR>Do you want the type also if you do then why not just WHERE UserName = &#039" & strUserName & "&#039".....why the AND....<BR><BR>This will give you everything.<BR><BR>you may wnat to try "AND (Type LIKE &#039Payment%&#039 OR Type=Void&#039)", objCustomerConn, adOpenDynamic just to check what it returns.<BR><BR><BR>

Posting Permissions

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