hi friends i need help in this sql query
i have table like,
id fid
__ _____
autonumber text
and i am storing values like
id fid
___________________________________
1 1,2,3,4,5
2 11,12,13,14,15
now to find values i am using query
sql = SELECT * FROM test12 WHERE `fid` LIKE ('%1%')
only problem in this query is it is selecting 1 and 11 and i require
only 1 as i am giving one in %1%
now any one have answer of this question then plz plz tell me ........ 4 1607
hardik wrote:
hi friends i need help in this sql query
i have table like,
id fid
__ _____
autonumber text
and i am storing values like
id fid
___________________________________
1 1,2,3,4,5
2 11,12,13,14,15
now to find values i am using query
sql = SELECT * FROM test12 WHERE `fid` LIKE ('%1%')
only problem in this query is it is selecting 1 and 11 and i require
only 1 as i am giving one in %1%
now any one have answer of this question then plz plz tell me ........
It seems like you are querying a database, that is not even in 1NF - you are
up to your neck in trouble. Rather than working on a single query you should
reorganise your database.
This particular query can be solved by
select *
from test
where fid = '1' -- singleton
or fid like '1,%' -- beginning of line
or fid like '%,1,%' -- middle of line
or fid like '%,1' -- end of line
All of this assuming that you have no spaces in fid.
--
Regards,
Kristian Damm Jensen
"This isn't Jeopardy. Answer below the question."
Am 16 Oct 2006 00:47:31 -0700 schrieb hardik:
....
id fid
___________________________________
1 1,2,3,4,5
2 11,12,13,14,15
now to find values i am using query
sql = SELECT * FROM test12 WHERE `fid` LIKE ('%1%')
only problem in this query is it is selecting 1 and 11 and i require
only 1 as i am giving one in %1%
now any one have answer of this question then plz plz tell me ........
If ',' is your separator you can use:
SELECT * FROM test12 WHERE `fid` = '1' or `fid` LIKE ('1,%') or
`fid` LIKE ('%,1,%') or `fid` LIKE ('%,1')
bye, Helmut
Thank you very much!
It works for me perfectly....
Kristian Damm Jensen wrote:
hardik wrote:
hi friends i need help in this sql query
i have table like,
id fid
__ _____
autonumber text
and i am storing values like
id fid
___________________________________
1 1,2,3,4,5
2 11,12,13,14,15
now to find values i am using query
sql = SELECT * FROM test12 WHERE `fid` LIKE ('%1%')
only problem in this query is it is selecting 1 and 11 and i require
only 1 as i am giving one in %1%
now any one have answer of this question then plz plz tell me ........
It seems like you are querying a database, that is not even in 1NF - you are
up to your neck in trouble. Rather than working on a single query you should
reorganise your database.
This particular query can be solved by
select *
from test
where fid = '1' -- singleton
or fid like '1,%' -- beginning of line
or fid like '%,1,%' -- middle of line
or fid like '%,1' -- end of line
All of this assuming that you have no spaces in fid.
--
Regards,
Kristian Damm Jensen
"This isn't Jeopardy. Answer below the question."
Kristian Damm Jensen wrote:
hardik wrote:
>hi friends i need help in this sql query
i have table like,
id fid __ _____ autonumber text
and i am storing values like
id fid ___________________________________ 1 1,2,3,4,5
2 11,12,13,14,15
now to find values i am using query
sql = SELECT * FROM test12 WHERE `fid` LIKE ('%1%')
only problem in this query is it is selecting 1 and 11 and i require only 1 as i am giving one in %1% now any one have answer of this question then plz plz tell me ........
It seems like you are querying a database, that is not even in 1NF - you are
up to your neck in trouble. Rather than working on a single query you should
reorganise your database.
http://en.wikipedia.org/wiki/First_normal_form
You shouldn't store multiple values in a single column. Instead, change
your table to look like this:
id fid
-- ---
1 1
1 2
1 3
1 4
1 5
2 11
2 12
2 13
2 14
2 15
and then you can simply do
select * from test12 where fid = 1
You should also use column names that are more descriptive than 'id' and
'fid', e.g. 'SalesOrderHeaderID' and 'SalesOrderLineID'. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: BVM |
last post by:
Hi, All:
I have this error. It seems execution time is too long. Actually the execution time is about 30 seconds(I tested in Query analyzer). How do I solve this problem?
...
|
by: pratchaya |
last post by:
This is my sample error in my MySQL Log
New value of fp=(nil) failed sanity check, terminating stack trace!
Please read http://www.mysql.com/doc/en/Using_stack_trace.html and
follow instructions...
|
by: Patrick Fisher |
last post by:
Hi
I have a table which Contains entries with RefCode field containing
INVP or INVPD
Common fields in each entry would be InvoiceNo, Total and PurTyp for
example.
You could have ...
|
by: salad |
last post by:
I'm curious about your opinion on setting relationships.
When I designed my first app in Access I'd go to Tools/Relationships and
set the relationships. Over time I'd go into the window and see...
|
by: arun |
last post by:
Query is too complex
--------------------------------------------------------------------------------
Hi, I was trying to solve this problem since last two days but couldn't
find any solution.
...
|
by: hardik |
last post by:
hi friends i need help in this sql query
i have table like,
id fid
__ _____
autonumber text
and i am storing values like
|
by: gsreenathreddy |
last post by:
Hi!
Please solve this query
in employee table in scott user i would like view the details of all the employees (empno, ename )who are working under which manager(mgr) .with his manager name...
|
by: fido19 |
last post by:
Once upon a time, there lived a chimpanzee called Luycha Bandor (aka Playboy Chimp).
Luycha was unhappily married to Bunty Mona, a short but cute little lady chimp. Luycha
was tall and handsome –...
|
by: xwebmaster |
last post by:
Hi
Please help me solving this query..
I have 3 tables..
comm_propDB
ID | User_ID | mls_num
-----|---------------|---------------------
2 | 2 | 5004
3 | 2 ...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |