LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using one SQL statement for selecting data from different tables

Hallo,

I was wondering if anyone could help me. I am trying to increase the speed of my program and reduce the SQL statements running on the maschine.
So i am trying to select data from 2 Tables with one Execute Query and a Fetch. But the only data returned is from the first table.
Now i am wondering if that is even possible.

for example
SqlStatement:

SELECT Sign from  TestNameSign where TestName ='TestName.vi';SELECT SignName, SignMin, SignMax, SignType, Changeable
FROM  TArticleSign

Thanks,
Oliver

0 Kudos
Message 1 of 9
(4,118 Views)
Doing two queries in one statement is not possible, as far as I know.

It is possible to get results form two (or more) tables if the tables are
connected. Google for INNER JOINT and OUTER
JOINT.

Without a connection between the tables, doing a query that gets results
from more then one table is still be possible,
but makes less sence.

Regards,

Wiebe.


0 Kudos
Message 2 of 9
(4,105 Views)
Thank you for your responds Wiebe,

Been using Inner Joint and Outer Joint.
The reason i've tried 2 Select on different tables, was that it is possible with SqlServer2005 so I wanted to see if it works as well in LabView and since i didn't get an Error I was wondering if it is possible,even maybe not logical Smiley Wink.
But oh well Smiley Happy it is good to know

cheers,
Oliver
0 Kudos
Message 3 of 9
(4,097 Views)
I don't have SQL Server 2005 - I only have 2000, but I looked at the SQL Server 2005 documentation because I was curious about your statement. I did not see in the documentation where it says you can create a query like you showed. Where did you see this in the documentation?

In terms of getting this data, a DataSet is designed to hold more than one table. So you would need to create DataSet objects from your SQL data and then you can access each table in the DataSet.
0 Kudos
Message 4 of 9
(4,082 Views)
Hallo smercurio..

I attached a screenshot what the return is of the SQLServer. It pretty much just creates to views on the table.




Message Edited by ofahed on 07-31-2008 04:20 AM
0 Kudos
Message 5 of 9
(4,068 Views)
That's 2 separate and distinct SQL statements. The semicolon separates the statements. That's not the same as a "merged" SELECT clause, which is what I thought you were implying. What you're seeing has been available since T-SQL pretty much first came out. As I indicated, if you want to capture the two tables you can use a DataSet.
0 Kudos
Message 6 of 9
(4,046 Views)
thanks smercurio...
you where right i thought i was using a "merged" SELECT, I will give Dataset a try 🙂
0 Kudos
Message 7 of 9
(4,016 Views)
You can use a UNION to connect two distinct queries. The only catch is that the number and datatypes of the columns returned have to be the same in both parts of the statement.

The biggest problem is that what you are trying to do doesn't make logical sense. The point of an SQL query is to define a set (in the mathematical sense of the word) containing the data you want. You are wanting to return data from queries that are returning sets of fundamentally different data.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

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

For help with grief and grieving.
Message 8 of 9
(3,995 Views)
Hi Mike,

Thanks for your responds.
I know it is not logical, I was just wondering if it even was possible. I guess formulated my question in the begining wrong.
I thought that Labview might return a multidimension array, for example SQL 2005 just returned 2 Tables.
For the better performance I just started using procedures or Views that join the Tables/Data I need.

Cheers Oliver

0 Kudos
Message 9 of 9
(3,983 Views)