MySQL Forums
Forum List  »  General

JOIN select only one row from second table
Posted by: Pankaj Mishra
Date: December 16, 2014 02:52AM

SELECT SensorName FROM Table1 WHERE Name = 'MyName';

Lets say, I get 5 rows back

Sensor1,
Sensor2,
Sensor3,
Sensor4,
Sensor5

Now in a different table, I have one row of data, this is the query

SELECT value1, value2, value3, value4, value5 from Table2 Where Name = 'MyName';

and this is what I get back.

value1 value2 value3 value value5
23.1669 14.5974 22.4009 19.9076 33.1585

"Name" is the common field on both the tables

Now I know these two are mapped (sensor names are mapped with the values), so How can I get Something like in single MySQL query

NAME VALUE
Sensor1 23.1669
Sensor2 14.5974
Sensor3 22.4009
Sensor4 19.9076
Sensor5 33.1585

Options: ReplyQuote


Subject
Written By
Posted
JOIN select only one row from second table
December 16, 2014 02:52AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.