在我将此条件添加到 WHERE 子句之前,下面显示的 php 查询工作正常(添加后查询结果为空白):
AND SUBSTR(company_id,1)='1'
基本上,我只想包括 company_id
中最后一位数字为“1”的公司。我该怎么做?
$data = mysqli_query($mysqli,"SELECT table1.company_abbrev, table2.company_name FROM table1, table2 WHERE table1.company_id=banks.company_id AND SUBSTR(company_id,1)='1' ORDER BY table2.company_name ");
最佳答案
试试这个
SUBSTR(company_id,-1)='1'
SUBSTRING(), the position of the first character in the string from which the
substring is to be extracted is reckoned as 1
有关更多详细信息,请参阅 dev.mysql.com
关于php - 包含 AND 子字符串条件的 WHERE 子句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26696285/