开发者

SQL Query: call all results which start with a letter

I am trying to call all results which start with a开发者_运维知识库 letter, for example purposes it needs to be the letter 'A'

My SQL Query is below could you please explain what I need to add.

$sqlTest="SELECT * FROM tbl_usersTest";

I am still having some errors. My whole code is

$sqlTest= "SELECT * FROM tbl_usersTest WHERE name LIKE 'A%'; 
$resultTest = mysql_query($sqlTest);
$rowTest= mysql_fetch_array($resultTest);
$loopPhone = 0;

while($rowmytelcoTest = mysql_fetch_array($resultTest))
{
$loopPhone++;
$TestName = $rowTest['name'];
$TestImageUrl = $rowTest['imageUrl'];
?>

All fixed now thanks

The problem was the case sensitivity of the value , And I was also missing the " at the end.


select * from tbl_usersTest where col_name like 'A%';

where col_name is the relevant column.


You might need to close your string properly:

// this:
$sqlTest= "SELECT * FROM tbl_usersTest WHERE name LIKE 'A%'";

// instead of this:
$sqlTest= "SELECT * FROM tbl_usersTest WHERE name LIKE 'A%'; 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜