Page 1 of 1
Comparing string
Posted: Thu Sep 27, 2007 3:13 am
by shivam0101
How do i fetch values from a table which will contain 2 characters
Example, field contains:
1. A123BCDE
2. A123CDEB
3. A123CEBF
4. A12CEBD3
and i want all the field values which contain CD.
i should get
1
2
4
Re: Comparing string
Posted: Thu Sep 27, 2007 3:18 am
by Chris Corbyn
shivam0101 wrote:How do i fetch values from a table which will contain 2 characters
Example, field contains:
1. A123BCDE
2. A123CDEB
3. A123CEBF
4. A12CEBD3
and i want all the field values which contain CD.
i should get
1
2
4
Code: Select all
if (strstr($input, "C") && strstr($input, "D")) {
//Then $input contains both C and D
}
Posted: Thu Sep 27, 2007 5:02 am
by shivam0101
Is it possible to get this values using only sql statment?
Posted: Thu Sep 27, 2007 5:42 am
by paulbm
Code: Select all
select string_field from strings_table where string_field like '%CD%'