如何在SQL语句中执行此操作
我对SQL语句有一个问题 此SQL语句工作正常,但我还想查找其如何在SQL语句中执行此操作,sql,Sql,我对SQL语句有一个问题 此SQL语句工作正常,但我还想查找其餐厅ID中有0的餐厅。我怎样才能在这份声明中做到这一点 SELECT ct.*, t.* FROM exp_channel_titles AS ct LEFT JOIN transactions AS t ON (ct.entry_id = t.restaurant_id) WHERE t.cardid > 0 ORDER BY t.created DESC 在where子句中添加和restaurant\u id=0在wher
餐厅ID
中有0的餐厅。我怎样才能在这份声明中做到这一点
SELECT ct.*, t.*
FROM exp_channel_titles AS ct
LEFT JOIN transactions AS t ON (ct.entry_id = t.restaurant_id)
WHERE t.cardid > 0
ORDER BY t.created DESC
在where子句中添加
和restaurant\u id=0
在where子句中添加和restaurant\u id=0
,您可以通过
WHERE t.cardid > 0 OR t.restaurant_id=0
如果cardid不是必须大于0的,您也可以使用和来确保t.cardd
也大于0您可以通过
WHERE t.cardid > 0 OR t.restaurant_id=0
如果cardid不是必须大于0的,您还可以使用和来确保在PHP中t.cardid
也大于0:
<?php
$result = mysql_query("SELECT
ct.*, t.*
FROM
exp_channel_titles as ct
LEFT JOIN
transactions as t on (ct.entry_id = t.restaurant_id)
WHERE
t.cardid > 0 and t.restaurant_id=0
order by t.created DESC");
while($row = mysql_fetch_array($result)){
echo $row['field'];
}
?>
在PHP中:
<?php
$result = mysql_query("SELECT
ct.*, t.*
FROM
exp_channel_titles as ct
LEFT JOIN
transactions as t on (ct.entry_id = t.restaurant_id)
WHERE
t.cardid > 0 and t.restaurant_id=0
order by t.created DESC");
while($row = mysql_fetch_array($result)){
echo $row['field'];
}
?>
通过拥有exp\u频道标题。id为0
的条目id
?通过拥有exp\u频道标题。id为0
的条目id
?当我这样做时,什么都不会出来。甚至连我的餐厅都没有。当我这样做的时候,什么都不会出来。甚至连我的餐厅都没有。当我这样做的时候,什么都不会出来。甚至连我的餐厅都没有。当我这样做的时候,什么都不会出来。甚至连我的餐厅都没有。当我这样做的时候,什么都不会出来。甚至连我的餐厅都没有。当我这样做的时候,什么都不会出来。甚至连我的餐厅都没有_id>0