我需要从表格中选择随机数据的帮助
让我们假设表中有10列,但我希望如果我在某个时候命中查询,它将带走所有数据,有时只从1列带走数据,而从1号和2列走出一段时间>
我该如何实现?
预先感谢
function selectAllInventoriesINGroup($conn,$groupname,$import_id)
{
$cgstSgst = explode('-', $groupname);
$sql = "SELECT * FROM stockitems WHERE generalid = '$import_id' AND cgst = '$cgstSgst[0]' AND sgst = '$cgstSgst[1]' ORDER BY RAND()";
$result = $conn->query($sql);
$jsonxx = mysqli_fetch_all ($result, MYSQLI_ASSOC);
return $jsonxx ;
}
我已经对此进行了测试,但是它从数据库中获取了所有数据
<?php
$sql = "SELECT * FROM stockitems WHERE generalid = '$import_id' AND cgst = '$cgstSgst[0]' AND sgst = '$cgstSgst[1]' ORDER BY RAND()";
?>