[英]Select columns with values using null
我有一個查詢來選擇不具有空值的列,但它不起作用..請告訴我問題出在哪里。 謝謝
$query= mysql_query("SELECT opt_one, opt_two, opt_three, opt_four, opt_five, opt_six FROM `table`
WHERE `opt_one` IS NOT NULL AND `opt_two` IS NOT NULL AND `opt_three` IS NOT NULL AND
`opt_four` IS NOT NULL AND `opt_five` IS NOT NULL AND `opt_six` IS NOT NULL AND q_id = '$id'")or die(mysql_error);
while($r3 = mysql_fetch_array($query))
{
$print = array($r3['opt_one'], $r3['opt_two'],
$r3['opt_three'],
$r3['opt_four'], $r3['opt_five'], $r3['opt_six']);
shuffle($print);
echo $print['0'];
echo '<br>';
echo $print['1'];
echo '<br>';
echo $print['2'];
echo '<br>';
echo $print['3'];
echo '<br>';
echo $print['4'];
echo '<br>';
echo $print['5'];
echo '<br>';
}
我認為您在列中具有空值而不是NULL 。 嘗試這個:
SELECT opt_one, opt_two, opt_three, opt_four, opt_five, opt_six
FROM `table`
WHERE (`opt_one` IS NOT NULL OR `opt_one` != '')
AND (`opt_two` IS NOT NULL OR `opt_two` != '')
AND (`opt_three` IS NOT NULL OR `opt_three` != '')
AND (`opt_four` IS NOT NULL OR `opt_four` != '')
AND (`opt_five` IS NOT NULL OR `opt_five` != '')
AND (`opt_six` IS NOT NULL OR `opt_six` != '')
AND q_id = '$id'
邊注:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.