我有这个问题:
SELECT *
FROM tbl_feedback
ORDER BY id DESC
我想只选择列'status'的字符串/ varchar“done”,列'type'是“bug”。
答案 0 :(得分:3)
非常简单
SELECT
*
FROM tbl_feedback
WHERE
[status] = 'done'
AND [type] = 'bug'
ORDER BY id DESC
答案 1 :(得分:0)
快速猜测 - 有关详细信息,请提供表格架构和一些演示数据。
SELECT * FROM tbl_feedback WHERE [status] = 'done' AND [type] = 'bug' ORDER BY id DESC
答案 2 :(得分:0)
这很简单,你需要在where子句中添加条件。
(function ($) {
//demo data
var contacts = [
{ name: "Contact 1", address: "1, a street, a town, a city, AB12 3CD", tel: "0123456789", email: "anemail@me.com", type: "family" },
{ name: "Contact 2", address: "1, a street, a town, a city, AB12 3CD", tel: "0123456789", email: "anemail@me.com", type: "family" },
{ name: "Contact 3", address: "1, a street, a town, a city, AB12 3CD", tel: "0123456789", email: "anemail@me.com", type: "friend" },
{ name: "Contact 4", address: "1, a street, a town, a city, AB12 3CD", tel: "0123456789", email: "anemail@me.com", type: "colleague" },
{ name: "Contact 5", address: "1, a street, a town, a city, AB12 3CD", tel: "0123456789", email: "anemail@me.com", type: "family" },
{ name: "Contact 6", address: "1, a street, a town, a city, AB12 3CD", tel: "0123456789", email: "anemail@me.com", type: "colleague" },
{ name: "Contact 7", address: "1, a street, a town, a city, AB12 3CD", tel: "0123456789", email: "anemail@me.com", type: "friend" },
{ name: "Contact 8", address: "1, a street, a town, a city, AB12 3CD", tel: "0123456789", email: "anemail@me.com", type: "family" }
];
//define product model
var Contact = Backbone.Model.extend({
defaults: {
photo: "/img/placeholder.png"
}
});
//define directory collection
var Directory = Backbone.Collection.extend({
model: Contact
});
//define individual contact view
var ContactView = Backbone.View.extend({
tagName: "article",
className: "contact-container",
template: $("#contactTemplate").html(),
render: function () {
var tmpl = _.template(this.template);
$(this.el).html(tmpl(this.model.toJSON()));
return this;
}
});
//define master view
var DirectoryView = Backbone.View.extend({
$el: $("#contacts"),
initialize: function () {
this.collection = new Directory(contacts);
this.render();
},
render: function () {
var that = this;
_.each(this.collection.models, function (item) {
that.renderContact(item);
}, this);
},
renderContact: function (item) {
var contactView = new ContactView({
model: item
});
this.$el.append(contactView.render().el);
}
});
//create instance of master view
var directory = new DirectoryView();
} (jQuery));
此处SQL FIDDLE可以与
一起玩您还可以使用列名称仅过滤select中的必需列
SELECT *
FROM tbl_feedback
WHERE status = 'done' and type= 'bug'
ORDER BY id DESC