Reputation: 763
When the result of a query exists, I want to know the name of the row(s) that have the correct results:
$query = "SELECT Id FROM Programacao WHERE ID = 1";
$curDate = date("Y-m-d H").':00:00';
$query = "SELECT Id
FROM Programacao
WHERE Data1 = '$curDate'
OR Data2 = '$curDate'
OR Data3 = '$curDate'"
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)){}
simply talking its if(Data1 == curDate)return Data1; if(Data2 == curDate)return Data2
....
Sorry for my bad english.
Upvotes: 0
Views: 82
Reputation: 115530
Perhaps you mean this? (either with UNION
or UNION ALL
):
$query = "
SELECT Id
, 'Data1' AS name
FROM Programacao
WHERE Data1 = '$curDate'
UNION
SELECT Id
, 'Data2'
FROM Programacao
WHERE Data2 = '$curDate'
UNION
SELECT Id
, 'Data3'
FROM Programacao
WHERE Data3 = '$curDate'
" ;
Upvotes: 0
Reputation: 72991
Well it would be Programacao
from your query. But if you needed it dynamically you could try functions like mysql_table_name()
or mysql_field_name()
.
Upvotes: 3
Reputation: 76567
A select statement does not go into a table.
It goes into a resultset.
Resultsets do not have names, they just are.
http://en.wikipedia.org/wiki/Result_set
Upvotes: 0