LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

multiple sql queries

I know this is not an appropriate question for this forum but is it possible to query the same table more than once at the same time using enterprise manager?

For example I have a table called BS_Results and It has a column I want called max_TX_out, can I write a query to say
'select max_TX_out from BS_Results where max_TX_out < 5.00 and max_TX_out > 0.50'

get the results for that query and then query the table again for

'select max_TX_out from BS_Results where max_TX_out < 10.00 and max_TX_out > 5.0'

but do all that at the 'same time', have multiple queries but from the same table looking at the same column but wanting different values from it?

e.g.


'select max_TX_out, from BS_Results where max_TX_out xxx;

'select max_TX_out, from BS_Results where max_TX_out zzz;
'select max_TX_out, from BS_Results where max_TX_out yyy;


The syntax above is obviously incorrect and will mot work in Enterprise manager, it is possible for me to do the same thing more or less using a different method?

does anyone know where I can find out?
Edge!
0 Kudos
Message 1 of 7
(3,492 Views)
Are you talking about the Enterprise Manager of SQL Server? If you are, then start Query Analyzer from the Tools menu and enter your queries into the query window. The queries will be done sequentially and you'll get 3 different results windows. If you want the results in a single window, then I think you'll have to write the query like a stored procedure - assigning variables and return values, etc. Once you've debugged it, then you can save the stored procedure which has the advantage of faster execution.
0 Kudos
Message 2 of 7
(3,492 Views)
You could use what is called a UNION statement. It would go something like:

select max_TX_out, from BS_Results where max_TX_out xxx
UNION
select max_TX_out, from BS_Results where max_TX_out zzz
UNION
select max_TX_out, from BS_Results where max_TX_out yyy;

However, it would probibly be better to use an OR in the qualification part of the statement as in:

select max_TX_out from BS_Results
where
max_TX_out xxx
OR
max_TX_out zzz
OR
max_TX_out yyy;

Actually, you would probibly want to do:

select distinct max_TX_out from BS_Results
where
max_TX_out xxx
OR
max_TX_out
out>zzz
OR
max_TX_out yyy;

The DISTINCT qualifier will prevent duplication of rows if the three ranges overlap.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 7
(3,492 Views)
I see how that works but the effect i am trying to achieve is not what came out when I run the query, this is what I am trying to achieve...
0 Kudos
Message 4 of 7
(3,492 Views)
Well yes, using Enterprise manager of SQL and also using the databse tool in Excel...this is what I ma trying to achieve...
Edge!
0 Kudos
Message 5 of 7
(3,492 Views)
If you want to do something like fill the first column with the results of query 'select max_TX_out, from BS_Results where max_TX_out xxx;', column 2 with 'select max_TX_out, from BS_Results where max_TX_out yyy;', etc., then I think the only way to do it is with three separate queries. Combining the queries with something like an OR will return a number of results but there's no way to determine which results are associated with the specific conditions. So if you decide to persue the stored procedure route, you would assign one variable to the results of the first query, a different variable to the results of the second, etc. These variables would be defined as parameters that get returned separately
when calling the stored procedure.
0 Kudos
Message 6 of 7
(3,492 Views)
One of the tricks of building systems incorporating a database is knowing what processing to do in SQL and what you want to do in LV. It is possible to implement the table you describe in SQL, but the logic would be very convoluted. A more efficient approach would be to read the entire column into LV and rearrange the values into your table there...

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 7 of 7
(3,492 Views)