我只是在网上冲浪,发现了一个类似的查询:
sql = "select milk_rate from special_milk_rate
where code_producer_id=? and effective_from <= ?
and effective_till >= ?"
Run Code Online (Sandbox Code Playgroud)
这个查询究竟意味着什么意味着什么是使用?在这个声明中.
还有一件事是在sql中使用&.
我正在尝试编辑一个 ETL 包(SSIS),该包查询 SQL 表并为每个 StationID 输出 csv 文件,但我无法理解下面的查询定义中如何使用问号。我明白 ?被用作参数,但我不明白它在下面的日期函数中是如何使用的:
SELECT TimeSeriesIdentifier, StationID, ParameterID FROM dbo.EtlView WHERE
LastModified > DATEADD(hour, ?*-1, GETDATE())
AND StationID LIKE
CASE WHEN ? = 0 THEN
StationID
ELSE
?
END
Run Code Online (Sandbox Code Playgroud) 我现在仍然在博客教程上学习YII,并对一些代码感到好奇.
在此链接
http://www.yiiframework.com/doc/blog/1.1/en/prototype.auth
有这样的代码
<?php
class UserIdentity extends CUserIdentity
{
private $_id;
public function authenticate()
{
$username=strtolower($this->username);
$user=User::model()->find('LOWER(username)=?',array($username));
if($user===null)
$this->errorCode=self::ERROR_USERNAME_INVALID;
else if(!$user->validatePassword($this->password))
$this->errorCode=self::ERROR_PASSWORD_INVALID;
else
{
$this->_id=$user->id;
$this->username=$user->username;
$this->errorCode=self::ERROR_NONE;
}
return $this->errorCode==self::ERROR_NONE;
}
public function getId()
{
return $this->_id;
}
}
Run Code Online (Sandbox Code Playgroud)
我对一些代码很好奇.
?>代码的最后一行没有?$user=User::model()->find('LOWER(username)=?',array($username));为什么用LOWER(username)=?不LOWER(username)=.为什么有需要?,是否有一些查询有条件我可能还不知道呢?我有这样的谈判表
id seller_id buyer_id property_id
1 4 190 33123
2 4 190 33123
3 5 191 34000
4 5 191 34000
5 6 200 35000
Run Code Online (Sandbox Code Playgroud)
我可以通过以下方式获取所有内容:
Negotiation.all
Run Code Online (Sandbox Code Playgroud)
我想取的一切,而是通过分组seller_id- buyer_id- property_id组合.在上面的例子中,我想返回三组.
这在我的rails应用程序中是否可行?
如果我使用查询生成器构建了以下查询:
$q = DB::table('Products')->whereExist(function ($q)
{
$q->select(DB::raw(1))
->from('tags_products')
->where('products.PorductId', '=', 'tags_products.ProductID');
});
Run Code Online (Sandbox Code Playgroud)
使用它翻译后的 SQL$q->toSql();是:
select * from `Products` where `exist` = (select 1 from `tags_products` where `products`.`ProductID` = ?)
Run Code Online (Sandbox Code Playgroud)
显然,查询生成器将tags_products.ProductID转换为?。
为什么变成了“?” ?
sql ×2
activerecord ×1
etl ×1
laravel ×1
php ×1
postgresql ×1
ruby ×1
sql-server ×1
ssis ×1
ssms ×1
yii ×1