这是我上一个问题的后续问题。我想写一个 MYSQL 语句来回显每个以字母 B 开头的条目。
函数.php
function getCategory() {
$query = mysql_query("SELECT author FROM lyrics WHERE author [starts with letter B]") or die(mysql_error());
while ($row = mysql_fetch_assoc($query)) { ?>
<p><a href="##"><?= $row['author']; ?></a></p>
<?php }
Category.php?category=b
<?php include 'includes/header.php' ?>
<?php getCategory(); ?>
<?php include 'includes/footer.php' ?>
我猜是这样的。然后一个用于字母表中的每个字母,一个用于杂项(数字等)
最佳答案
SELECT author FROM lyrics WHERE author LIKE 'B%';
不过,请确保您对 author
有一个索引!
关于mysql - 选择所有[第一个字母以B开头]的地方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10156965/