我无法将此代码转换为codeigniter。请帮忙
SELECT * FROM table1
LEFT JOIN table2 ON table2.number = table1.number
WHERE table2.number IS NULL
答案 0 :(得分:2)
使用以下代码。
$this->db->select('*');
$this->db->from('table1');
$this->db->join('table2 ', 'table2.number = table1.number','left');
$this->db->where('table2.number IS NULL');
$query = $this->db->get();
答案 1 :(得分:1)
试试这个
if($this->db->query('SELECT * FROM table1 LEFT JOIN table2 ON table2.number = table1.number WHERE table2.number IS NULL') )
{
echo 'success';
}
else
echo 'check your query';
示例:
var async = require('async');
var prodAdvOptions = {
host : "webservices.amazon.in",
region : "IN",
version : "2013-08-01",
path : "/onca/xml"
};
var prodAdv = aws.createProdAdvClient(awsAccessKeyId, awsSecretKey, awsAssociateTag, prodAdvOptions);
var n=100;//Just for test
var i = 0; // part 1 of for loop (var i = 0)
async.whilst(
function () { return i <= n; }, // part 2 of for loop (i <=n)
function (callback) {
prodAdv.call("ItemSearch", {
SearchIndex : "All",
Keywords : "health,fitness,baby care,beauty",
ResponseGroup : 'Images,ItemAttributes,Offers,Reviews',
Availability : 'Available',
ItemPage : 1
}, function(err, result) {
if (err) {
console.log(err);
} else {
console.log(result);
}
i++; // part 3 of for loop (i++)
callback();
});
},
function (err) {
console.log('done with all items from 0 - 100');
}
);
答案 2 :(得分:0)
$this->db->where('table2.number IS NOT NULL', null, false)
OR
$this->db->where(array('table2.number' IS NOT NULL));
答案 3 :(得分:0)
你可以这样做。
$this->db->select('*');
$this->db->from('table1');
$this->db->join('table2 ', 'table2 .user_id = table1.id','left');
$this->db->where('table1.users_id', $id);
$query = $this->db->get();
答案 4 :(得分:0)
使用它:
$this->db->select('*')
->from('table1')
->join('table2 ', 'table2.number = table1.number','left')
->where('table2.users_id', NULL );
$query = $this->db->get();