查询结果的表名

发布于 2024-12-04 21:28:48 字数 468 浏览 3 评论 0原文

当查询结果存在时,我想知道具有正确结果的行的名称:

$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)){}

只需谈论其 if(Data1 == curDate)return Data1; if(Data2 == curDate)return Data2...

抱歉我的英语不好。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

明月松间行 2024-12-11 21:28:48

那么,您的查询将是 Programacao 。但如果你动态需要它,你可以尝试像 mysql_table_name 这样的函数()mysql_field_name ()

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().

花开雨落又逢春i 2024-12-11 21:28:48

select 语句进入表。
它进入结果集。
结果集没有名称,但它们就是有名称。

http://en.wikipedia.org/wiki/Result_set

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

寂寞美少年 2024-12-11 21:28:48

也许你的意思是这个? (使用 UNIONUNION 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'
         " ;

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'
         " ;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文