我想用php选择一个随机数据

I need help in selecting a random data from the table

Let's suppose There are 10 columns in my table but i want that if I hit the query sometime it will bring all data and sometime it will bring data only from 1 column and some time from the no 1 and no 2 column

How can I achieve this?

Thanks in advance

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 ;
}

I have tested this but it fetch the all the data from the database

<?php
  $sql = "SELECT * FROM stockitems WHERE generalid = '$import_id' AND cgst = '$cgstSgst[0]' AND sgst = '$cgstSgst[1]' ORDER BY RAND()";
?>