Make part of a query conditional?

Results 1 to 2 of 2

Thread: Make part of a query conditional?

  1. #1
    Quervo Guest

    Default Make part of a query conditional?

    set rs= Conn.Execute(" SELECT TwoThousandDescriptions.proddesc, <BR>Can I make part of a query conditional, that if there is a value in the table, then include it in the query, but if it the value is not in the table, ignore it in the query?<BR><BR>In the following query, I only want it to INNER JOIN on the VIP1 table if the Join Fields have data matching the TwoThousandDescriptions fields. Otherwise, <BR><BR>TwoThousandDescriptions.retail,, ECPVendor.code, VIP1.price FROM TwoThousandDescriptions INNER JOIN "_<BR> & " ECPVendor ON TwoThousandDescriptions.vcode = ECPVendor.code INNER JOIN VIP1 ON TwoThousandDescriptions.vcode=VIP1.vcode and TwoThousandDescriptions.prodid=VIP1.prodid "_<BR> & " WHERE (TwoThousandDescriptions.proddesc like &#039;%"&tmparr(i)&"%&#039;)")

  2. #2
    Join Date
    Dec 1969

    Default RE: Make part of a query conditional?

    maybe like this/for sql server only/:<BR>SELECT T.proddesc,T.retail,,E.code<BR>FROM TwoThousandDescriptions T,ECPVendor E<BR>WHERE Exist<BR>(Select V.vcode,V.prodid,E.code<BR>From VIP1 V,ECPVendor E<BR>Where T.vcode = E.code and T.vcode=V.vcode and T.prodid=V.prodid and T.proddesc like &#039;%"&tmparr(i)&"%&#039;)<BR>but it is the same as with join...

Posting Permissions

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