开发者

a bugging query

开发者 https://www.devze.com 2022-12-25 12:23 出处:网络
i need to get a query where the elements are displayed in case the first letter is E (the word is electronics).. i have tried with the following :

i need to get a query where the elements are displayed in case the first letter is E (the word is electronics).. i have tried with the following :

mysql_query("select * from nested_category where name 开发者_开发技巧like '[A-F]%'");

Edit : its like i need to choose all the elements for which the first element lie between A & F .. I need all the element such as Elements, Capacitors, Elephant, Accelerators and definitely not Resistors.. I am using this query with PHP...


WTF has A-F got to do with E?

SELECT * FROM nested_category WHERE name LIKE 'E%'

In response to your edit:

Use the REGEXP function:

SELECT * FROMnested_category WHERE name REGEXP '^[A-E]'

And even still, you now say you want A-E, but your code says A-F? I'm really confused by your question...


The only way to continue using the mySql LIKE syntax is this:

mysql_query("SELECT *
FROM nested_category
WHERE
(name LIKE 'A%'
OR name LIKE 'B%'
OR name LIKE 'C%'
OR name LIKE 'D%'
OR name LIKE 'E%')");
0

精彩评论

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

关注公众号