Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Five SQLs in One

Status
Not open for further replies.

patweb

Programmer
Apr 17, 2003
174
BE
I have made an SQL with 5 boolean fiels (yes or no value). The result with AND or OR is NOK. To many or to few records.

page boolean1 boolean2 boolean3 boolean4 boolean5
page1 yes no no no no
page2 no yes no no no
page3 no no no yes yes

I see a possible solution.
I make 5 SQLs, each SQL select one boolean (on yes)

Afterwards I like to make one SQL or one result out of the SQLs where there is yes.

How to contatenate SQL1 + SQL2, only the first field is valuable.

pat.
 
With your posted input sample, what is the expected result ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
The result of AND or OR is NOT OK. I need only [PAG-ned-text] where the result in one or more 5 boolean fields is YES. My table is Ok. The combination of YES and NO gives an unwanted result. Tested with AND or OR.

"SELECT [T-LOOKUP-PAG].[PAG-ned-text], [T-LOOKUP-PAG].ICG, [T-LOOKUP-PAG].BEL, [T-LOOKUP-PAG].RVB, [T-LOOKUP-PAG].TWB, [T-LOOKUP-PAG].[SUP DBS], [T-LOOKUP-PAG].IDC " _
&" FROM [T-LOOKUP-PAG]" _
& "WHERE ((([T-LOOKUP-PAG].[SUP DBS]) = " & SUPDBS & ")) or ((([T-LOOKUP-PAG].BEL) = " & BEL & ")) or ((([T-LOOKUP-PAG].IDC) = " & IDC & ")) or ((([T-LOOKUP-PAG].TWB) = " & TWB & ")) or ((([T-LOOKUP-PAG].ICG) = " & ICG & ")) or ((([T-LOOKUP-PAG].RVB) = " & RVB & ")) ;"
 
try either of these --
Code:
select ...
  from [T-LOOKUP-PAG]
 where [SUP DBS]
    or BEL
    or IDC
    or TWB
    or ICG
    or RVB
Code:
select ...
  from [T-LOOKUP-PAG]
 where [SUP DBS] <> 0
    or BEL <> 0
    or IDC <> 0
    or TWB <> 0
    or ICG <> 0
    or RVB <> 0

rudy | r937.com | Ask the Expert | Premium SQL Articles
SQL for Database-Driven Web Sites (next course starts March 6 2005)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top