Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need to retrieve a list of words, but don't want any words that contain a number or numbers in them.
The idea is very simple, but I'm not even sure how to try. I have one column of words some of which have numbers in them. I only want to retrieve the ones without numbers.
How would I do this in my SQL query?
Thanks
Use a regular expression, either with php's preg_match, or with REGEXP in mysql.
SELECT list_col FROM list_table WHERE list_col NOT REGEXP '[0-9]'
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
i have a query that in table replies i have to add few words seperated by commas
Like a user said
How are you
so it should store the txt like 'how,are,you'
...
and how will i fetch the the text from the cell
Basically it should be like
User submits a reply to a bot in which
the bot will give the reply on the bases of the words ...
You can use str_replace so you can replace all spaces with commas.
Something like
str_replace(' ', ',', $userstring)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm not very good at regular expressions. Please help make the expression.
$subject = "action[attribute1=value1,attribute2=values,...]";
// format is ^word[str=str,...]$
I need to match "action", "attributes" and "values". thanks.
First find a match with regex pattern \b(\w+)\[((?:(?<=[,\[])(?:\w+)=(?:[^,\]]+)[,\]]?)+)]
to get action name as Group 1 and parameter list as Group 2.
In next step apply regex pattern (?:^|(?<=,))(\w+)=([^,\]]+)(?=,|$) to Group 2 from above regex
to get a list of attributes and associated values...
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a list of number in my database and wanna list them like this:
1
11
111
11101
11101001
11101002
11102
11102001
11102002
11102003
11102004
11103
Any suggestions?
You want to sort the items as strings. This way, "11101002" comes before "11102".
The parameter SORT_STRING will achieve that when sorting an array with sort():
sort($myarray, SORT_STRING);
You will need to populate an array with the data from your database.
Other option, possibly less costly, is to sort them directly when querying the DB, by using ORDER BY.
What you wanna do is to treat your numbers like strings.
You can CAST or CONVERT your numbers to strings :
ORDER BY CAST(my_numeric_column AS CHAR(50))
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I suck at regexp but i'd like to just do a simple filter where / is replaced with 1, " is replaced with 2 and < is replaced with 3.
I'd appreciate an example where the syntax would be straight forward, i'd like to run this filter through the input of a get variable provided by the user. A syntax like:
replace(/,1)
replace(",2)
replace(<,3)
.
Thanks.
I really don't see the need for regex here.. You can just use str_replace
E.g.
str_replace('/', '1', $_GET['var']);
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Can I use this php code wih WHERE? SELECT SUM(buzz) as buzz FROM $table I want to calculate sumation of some spesific rows.
If you want specifically in PHP then this might help you
SELECT SUM(buzz) as buzz FROM $table WHERE $where
No, you can't use PHP code in an SQL where condition. Databases typically don't include a PHP interpreter.
What you can do is use PHP to generate the where clause that you need.