08-10-2015 09:20 PM
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 ?
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 ?
08-10-2015 10:35 PM
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.
08-10-2015 10:36 PM
08-10-2015 10:46 PM
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 ?
08-11-2015 12:58 AM
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.
Tis 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);
08-11-2015 01:16 AM
08-11-2015 04:05 AM
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.
I nid to get tis value , The time of highest wind speed.
08-11-2015 07:07 AM
08-11-2015 02:52 PM
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.
08-11-2015 09:31 PM
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 !!