Results 1 to 9 of 9
Related
-
Problem in saving data Forum: PHP Forum
Replies: 1 -
PHP code for selecting data from html table Forum: PHP Forum
Replies: 1 -
Random pictures in each table data cell Forum: HTML Forum
Replies: 0 -
Matching a certain date format from a String? Forum: CGI Perl Forum
Replies: 0
-
10-09-2006, 03:32 PM #1
Please Help problem fetching data from table (String Matching)
Hi guys ,
Here is my problem,
I have a table named abc which have a column id_number
table abc
-----------------------------------------------
|id_number name
----------------------------------------
012 albert
014 sam
045 anthony
023 john
----------------------------------
and I have some string suppose 023456987
Now what i have to do is to select the values from table which matches to the string .
in this case it should display 023 john
I am trying this query:
select * from abc where '023456987' like id_number+'%';
this query works fine in MSSQL server but doesn't works in MYSQL.
Please solve this problem how can i get the wanted result.
Thanks In Advance.
vids
-
10-09-2006, 06:05 PM #2
Re: Please Help problem fetching data from table (String Matching)
Do you want to match the whole string or just a substring? You won't get a match with 023 john for that whole string.
Music Around The World - Collecting tips, trade
and want lists, album reviews, & more
-
10-10-2006, 02:47 PM #3
Re: Please Help problem fetching data from table (String Matching)
HI vinyl-junkie ,
First of all Thanks a lot.
whole string from table should match to the external string.
suppose external string is 023456 and the entries in table are 023 and 0234 then it should select 0234.
Can I get you online on yahoo.My yahoo id is vids_cs@yahoo.com
-
10-10-2006, 10:23 PM #4
Re: Please Help problem fetching data from table (String Matching)
Sorry, I don't use IM. I also prefer to give answers publicly on the forum, so that others may possibly benefit from the answers as well.
Your select statement should look something like this, if I understand correctly what you're saying.
Code:select * from abc where id_number like '%023%'
Hope this helps.Music Around The World - Collecting tips, trade
and want lists, album reviews, & more
-
10-14-2006, 02:46 PM #5
Re: Please Help problem fetching data from table (String Matching)
No i think you did not understand properly let me explain again
I have a number in a variable suppose $A= 023897487
now what i have to do is to check the most matching value from the field id_number
suppose
id_number
-------------------
023
0238
0245
02356
0123
So if the number
$ A=023897487 then it should select 0238
if $ A=0235496487 then it should select 023
if $ A=0235696487 then it should select 02356
if $ A=01234697487 then it should select 0123
I hope you understand the problem now .
Thanks
-
10-14-2006, 05:19 PM #6
Re: Please Help problem fetching data from table (String Matching)
If I understand what you're telling me, you're matching on the sequence of numbers and not the variable itself. I'm sure there's a way of doing it, but it would likely involve some pretty extensive coding. Maybe you could do it with a regular expression, but I'm no good at that.
Music Around The World - Collecting tips, trade
and want lists, album reviews, & more
-
10-17-2006, 12:33 PM #7
Re: Please Help problem fetching data from table (String Matching)
I agree with vinyl - it looks perfect for reg-ex - but there's whole books just on that topic, and I'm not knowledgeable in this area.
-
10-19-2006, 03:00 PM #8
Re: Please Help problem fetching data from table (String Matching)
hmm then its my badluck .
Anyways thank you for you help
-
10-20-2006, 04:26 AM #9
Re: Please Help problem fetching data from table (String Matching)
I discovered this site - looks like this could be the place to look for a solution ...
http://regexlib.com/
Cloudjiffy- PaaS for Developers
10-05-2020, 12:30 AM in Web Hosting Forum