|
Posted by Ed Murphy on 10/17/06 04:10
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'.
Navigation:
[Reply to this message]
|