首页 \ 问答 \ 如果我的ID存在于结果中,请检查MySQL表(Check in MySQL table if my ID exist in the results)

如果我的ID存在于结果中,请检查MySQL表(Check in MySQL table if my ID exist in the results)

如果我的ID存在于结果中并且返回TRUE,如何检查MySQL表,但这有点复杂,因为我想检查记录的GROUP而不是该GROUP的最后一个,下面的代码用于表和查询不行,我想检查我的$session_user_id存在于GROUP OF auction_bid_item_id但不检查最后一行,因为最后一行是WINNING ROW。

CREATE TABLE `auction_bids` (   
    `auction_bid_id` int(11) NOT NULL AUTO_INCREMENT,   
    `auction_bid_user_id` int(11) NOT NULL,  
    `auction_bid_seller_id` int(11) NOT NULL,   
    `auction_bid_item_id` int(11) NOT NULL,   
    PRIMARY KEY (`auction_bid_id`) 
);

MySQL查询:

SELECT * FROM auction_bids 
WHERE auction_bid_user_id = '$session_user_id' 
GROUP BY auction_bid_item_id;

How to check in MySQL table if my ID exist in the results and return TRUE, but this is a little complicated as I would like to check GROUP of records and not the last one from that GROUP, code below for the table and query which doesn't work, I would like to check if my $session_user_id exist in the GROUP OF auction_bid_item_id but not check last row as the last row is a WINNING ROW.

CREATE TABLE `auction_bids` (   
    `auction_bid_id` int(11) NOT NULL AUTO_INCREMENT,   
    `auction_bid_user_id` int(11) NOT NULL,  
    `auction_bid_seller_id` int(11) NOT NULL,   
    `auction_bid_item_id` int(11) NOT NULL,   
    PRIMARY KEY (`auction_bid_id`) 
);

MySQL Query:

SELECT * FROM auction_bids 
WHERE auction_bid_user_id = '$session_user_id' 
GROUP BY auction_bid_item_id;

原文:https://stackoverflow.com/questions/17611434
更新时间:2022-10-25 20:10

最满意答案

“从多个键中删除数据”:

function batch_remove($key=null, $columns=null, $super_column=null, $write_consistency_level=null) {

    $timestamp = CassandraUtil::get_time();
    $deletion = new cassandra_Deletion();
    $deletion->timestamp = $timestamp;

    if ($super_column !== null) $deletion->super_column = $this->pack_name($super_column, true);
    else $deletion->super_column = null;

    if ($columns !== null) {
        $predicate = $this->create_slice_predicate($columns, '', '', false, self::DEFAULT_COLUMN_COUNT);
        $deletion->predicate = $predicate;
    }

    $mutation = new cassandra_Mutation();
    $mutation->deletion = $deletion;

    if (is_array($key) && count($key) >= 1) {

        $mut_map = array();
        foreach($key as $v) {
            $packed_key[$v] = $this->pack_key($v);
            $mut_map[$v] = array($this->column_family => array($mutation));
        }

        return $this->pool->call("batch_mutate", $mut_map, $this->wcl($write_consistency_level));

    } else return false;

}

//delete name1, name2, name3 from key1, key2 in a single call
$column_family->batch_remove(array(key1, key2), array(name1, name2, name3));

"delete data from multiple keys":

function batch_remove($key=null, $columns=null, $super_column=null, $write_consistency_level=null) {

    $timestamp = CassandraUtil::get_time();
    $deletion = new cassandra_Deletion();
    $deletion->timestamp = $timestamp;

    if ($super_column !== null) $deletion->super_column = $this->pack_name($super_column, true);
    else $deletion->super_column = null;

    if ($columns !== null) {
        $predicate = $this->create_slice_predicate($columns, '', '', false, self::DEFAULT_COLUMN_COUNT);
        $deletion->predicate = $predicate;
    }

    $mutation = new cassandra_Mutation();
    $mutation->deletion = $deletion;

    if (is_array($key) && count($key) >= 1) {

        $mut_map = array();
        foreach($key as $v) {
            $packed_key[$v] = $this->pack_key($v);
            $mut_map[$v] = array($this->column_family => array($mutation));
        }

        return $this->pool->call("batch_mutate", $mut_map, $this->wcl($write_consistency_level));

    } else return false;

}

//delete name1, name2, name3 from key1, key2 in a single call
$column_family->batch_remove(array(key1, key2), array(name1, name2, name3));

相关问答

更多
  • 与给定键相关的所有东西都是原子的(这就是为什么batch_mutate允许多个CF具有单个键)。 Everything associated w/ a given key is atomic (which is why batch_mutate allows multiple CFs w/ a single key).
  • Applications组件目录自动加载,因此您不需要更改配置。 我不熟悉phpcassa,但要检查的内容包括: - 文件名是否与类名相同? phpcassa是否包含子类? 默认情况下,这些不会自动加载。 编辑:嗨,尝试在你的bootstrap中使用Yii :: registerAutoloader。 使用Zend,我使用这样的代码: - Yii::import('application.vendors.*'); require "Zend/Loader/Autoloader.php"; Yii::regi ...
  • Vanilla hadoop由核心的分布式文件系统(DFS)和支持Map Reduce模型编写程序进行分析的库组成。 DFS使Hadoop具有可扩展性。 它负责将数据分块到多节点集群中的多个节点,以便Map Reduce可以处理单个数据块可用节点,从而实现并行性。 可以在此处找到作为Hadoop分布式文件系统(HDFS)基础的Google文件系统的文章 Map Reduce模型的论文可以在这里找到 有关Map Reduce的详细说明,请阅读本文 Cassandra是一个高度可扩展,最终一致,分布式,结构化的 ...
  • “从多个键中删除数据”: function batch_remove($key=null, $columns=null, $super_column=null, $write_consistency_level=null) { $timestamp = CassandraUtil::get_time(); $deletion = new cassandra_Deletion(); $deletion->timestamp = $timestamp; if ($super_ ...
  • 来自http://wiki.apache.org/cassandra/API : 突变 Mutation封装要插入的列或要为密钥执行的删除。 与ColumnOrSuperColumn一样,这两个属性是互斥的 - 您只能在Mutation上设置一个属性。 From http://wiki.apache.org/cassandra/API: Mutation A Mutation encapsulates either a column to insert, or a deletion to execute f ...
  • 我们在Cassandra上工作的团队围绕这个问题做了一些RND,并发现它与Cassandra 1.2和旧版本有关。 如果我们选择特定的列,一旦行大小超过64 KB,Cassandra就会停止读取行。 如果用户选择完整的行,那么它工作正常。 Our team working on the Cassandra did some RND around this issue and figured out that it is issue with Cassandra 1.2 and older version. ...
  • 最后,我没有搞砸TSocket $ persist参数......相反,我们编译了phpcassa自带的thrift库并启用了apc(我没有明确缓存连接池,但apc是opcode缓存等)。 在这两次更改之间,三个池的连接池设置时间都缩短到了一位毫秒级的范围......这意味着我正在处理其他瓶颈问题。 In the end I didn't mess with the TSocket $persist parameter... instead we compiled the thrift library th ...
  • 我确认这是连接器中的错误。 正在为单个预准备语句设置一致性级别,并且在我们使用批处理语句时将被忽略。 按照连接器上的更新 - 修复程序将包含在下一个错误修复版本中。 I confirm that this is a bug in connector. Consistency level is being set on individual prepared statements and is simply ignored in case when we use batch statements. Follo ...
  • 要回答提出的问题:你可能会遇到PHP max_execution_time - PHP配置:max_execution_time和max_input_time 更一般地说,虽然我会说这不是在Cassandra中建模数据的好方法。 如果您需要处理大量数据,请使用Hadoop( http://wiki.apache.org/cassandra/HadoopSupport ); 否则,您应该对事物进行建模,以便从单行或索引中获取所需的数据。 To answer the question as posed: you ...
  • 谢谢大家!我找到了解决方案。 只需要解压缩('N',$ value); 或者修改一下phpcassa的ColumnFamily类,它使用这个(解包)函数,但是这个函数是私有的 Thanks to all!I found a solution. just needs to unpack('N', $value); or to modify a bit phpcassa's ColumnFamily class, it uses this(unpack) function, but this function ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)