LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting the value from mysql with the same row.

Im able to show the highest wind speed from a column of mysql in labview with select Max function, but how can i get the time of highest wind speed from mysql to labview ?

 

New Picture.JPG

 

My connection to mysql is as below, Getting the highest wind speed with select max function. The wind speed will update once a higher wind speed is logged. So the time must same with the row of wind speed. How could i do tis ?

New Picture (1).JPG

0 Kudos
Message 1 of 11
(4,031 Views)

SELECT * FROM table

ORDER BY speed DESC

LIMIT 1

 

or

 

SELECT * FROM table

WHERE speed = (SELECT MAX(speed) FROM table)

 

On my phone so I did not bother to get the column or table names exact, but you get the idea.  I usually use the first form because it is simple to add a WHERE clause for say today or the past 24 hours. 

0 Kudos
Message 2 of 11
(3,984 Views)
You actually have to include the column in your query.
0 Kudos
Message 3 of 11
(3,979 Views)

Thanks darin and deniss. I will try out ur method darin, Dennis do u means that include time column together with the select max  command text there ?

0 Kudos
Message 4 of 11
(3,969 Views)

Darin.k i using tis code 

SELECT * FROM table

ORDER BY speed DESC

LIMIT 1

 

It show me Date of the highest wind speed only. Can it be Time ? or Both Date and Time.

 

WindSpeed and Time.JPGTis cant work.

 

SELECT * FROM table

WHERE speed = (SELECT MAX(speed) FROM table)

 

. Is it like tis.

 

SELECT * FROM table

WHERE Time = (SELECT MAX(WindSpeed) From table);

0 Kudos
Message 5 of 11
(3,876 Views)
If you use the astrisk in the select, you will get all columns from the table in the order they are defined.

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 6 of 11
(3,863 Views)

i removed the * symbol ady. 

 

SELECT Time FROM wind_speed_data

WHERE WindSpeed = (SELECT MAX(WindSpeed) FROM wind_speed_data);

 

When i key in the command like tis, it show me Date and Time, and the date is today's date , 2015-8-11, not 2015-8-4, date of the highest wind speed.

 

 

When i change Time > Date

SELECT Date FROM wind_speed_data

WHERE WindSpeed = (SELECT MAX(WindSpeed) FROM wind_speed_data);


It show me the right value 2015-8-4.

 

WindSpeed and Time.JPG

I nid to get tis value , The time of highest wind speed. 

New Picture.JPG

 

0 Kudos
Message 7 of 11
(3,804 Views)
I would say then that the problem is that you are using reserved keywords as column names. Column names should be specific, like the name of a VI.

Why do you have date and time in two separate columns?

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 8 of 11
(3,784 Views)

time and date are both MySQL functions on datetime objects, so they would be used as time(x) or date(x), should not be an issue in this case.  In general, yes, it is better to avoid reserved names when possible.

 

I do not use the DCT, but as pointed out by Mike you are probably better off using a datetime column instead of separate date and time.  The time format in MySQL is meant for elapsed time, not really time of day.   Using a datetime column provides a single primary key which makes it simpler to update the table, and is just easier overall IMO.  In MySQL if you insert a time object into a datetime column then the time is added to the current date, perhaps the LV DCT is doing something similar and returning a time value as a timestamp with the date chosen as the current date.

 

VIs are preferred to pictures, at the least you need to show more info.  In particular, we need to see the resulting 2D string array from your query, all elements, not just 1, and with sufficient width to know we are seeing the entire string.

Message 9 of 11
(3,755 Views)

Thanks darin and mike, i combine the column of Date and time and set the format to datetime, and i can get the correct date , time of highest wind speed after that. it can works now ! thanks !!

0 Kudos
Message 10 of 11
(3,735 Views)