相关疑难解决方法(0)

问号在SQL查询中表示什么?

在浏览一些SQL书籍时,我发现示例往往?在查询中使用问号().它代表什么?

sql prepared-statement

43
推荐指数
3
解决办法
8万
查看次数

什么是在SQL中使用问号

我只是在网上冲浪,发现了一个类似的查询:

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中使用&.

sql

7
推荐指数
1
解决办法
3万
查看次数

问号在 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)

sql-server ssis etl ssms

4
推荐指数
1
解决办法
2737
查看次数

YII CActiveRecord-> find()

我现在仍然在博客教程上学习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)

我对一些代码很好奇.

  1. 为什么?>代码的最后一行没有?
  2. 在这条线$user=User::model()->find('LOWER(username)=?',array($username));为什么用LOWER(username)=?LOWER(username)=.为什么有需要?,是否有一些查询有条件我可能还不知道呢?

php yii yii-cactiverecord

2
推荐指数
1
解决办法
7713
查看次数

通过组合多个列来组合结果集

我有这样的谈判表

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应用程序中是否可行?

ruby postgresql activerecord ruby-on-rails

2
推荐指数
1
解决办法
1559
查看次数

Laravel 查询生成器:whereExists 将条件子句转换为问号

如果我使用查询生成器构建了以下查询:

$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转换为

为什么变成了“?”

query-builder laravel

1
推荐指数
1
解决办法
1344
查看次数