我有以下打印出数字列表的查询。我想将每个唯一数字限制为 1。
比如数据库中有3个18,则打印出18、18、18,如果是5的两次出现,则打印出5,5。我只显示 18,在这种情况下为 5。
let sqlSelectBoxInformation = "SELECT longestDimension from box ";
connectionBoxInformation.query(sqlSelectBoxInformation, function(err, rows, fields) {
if (!err) {
// Check to see if the user entered hashtag is found in the database
// Create a variable to track if the item was found
var data = {
rows: rows,
userHashtag: databaseHashtag
}
res.render('delivery/chooseBox', data);
}
});
最佳答案
你可以使用DISTINCT
:
SELECT DISTINCT longestDimension from box
或分组依据
SELECT longestDimension from box GROUP BY longestDimension
关于javascript - 将列表的每次出现限制为 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42741736/