需要选择语句 [英] select statement needed
问题描述
我需要一个MySQL select语句作为PHP脚本的一部分。我想找到
行,其中某列以某个列开头或等于用户提供的
字符串。该字符串的长度为1个或多个字符。
发送页面允许用户选择他想要的b $ b想要的搜索条件,所以这个(和许多其他的) select语句可能不存在或者b / b
。声明始终以
来自logdata的SELECT *,其中driver =''$ _COOKIE [用户名]''
如果用户已选择它们并提供了适当的搜索数据,
其他元素将被添加到查询字符串中。例如,它可能
看起来像
SELECT *来自logdata,其中driver =''$ _COOKIE [username]''AND amount> =
$ _POST [txtLowAmount]和金额< = $ _POST [txtHighAmount]和餐厅
regexp ???
我''我甚至不确定这是否是regexp所属的地方,或者是否应该如何使用
。
最后,我希望它不区分大小写。 />
以下是我想要的一些例子:
如果用户字符串是CHIL
辣椒的真实
查理的假是
CHIL true
ch false
提前谢谢你/>
Jeff Sandler
I need a MySQL select statement as part of a PHP script. I want to find
rows where a certain column either starts with or equals a user-supplied
string. The string will be 1 or more characters in length.
The sending page allows the user to choose which search criteria he
wants, so this (and many other) pieces of the select statement may or
may not be present. The statement always starts with
SELECT * from logdata where driver = ''$_COOKIE[username]''
If the user has selected them and supplied the proper data for a search,
other elements will be added to the query string. For example, it may
look like
SELECT * from logdata where driver = ''$_COOKIE[username]'' AND amount >=
$_POST[txtLowAmount] AND amount <= $_POST[txtHighAmount] AND restaurant
regexp???
I''m not even sure if that is where a regexp belongs or if that is how it
should be used.
Ultimately, I would prefer it be non case sensitive.
Here are some examples of what I want:
If the user string is "CHIL"
Chili''s true
Charlie''s false
CHIL true
ch false
Thank you in advance
Jeff Sandler
推荐答案
_COOKIE [用户名]''
如果用户已选择它们并提供适当的搜索数据,
其他元素将添加到查询字符串中。例如,它可能
看起来好像
SELECT * from logdata where driver =''
_COOKIE[username]''
If the user has selected them and supplied the proper data for a search,
other elements will be added to the query string. For example, it may
look like
SELECT * from logdata where driver = ''
_COOKIE [username ]''和金额> =
_COOKIE[username]'' AND amount >=
_POST [txtLowAmount]和金额< =
_POST[txtLowAmount] AND amount <=
这篇关于需要选择语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!